You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1136,54 +1136,198 @@ SELECT tryBase58Decode('3dc8KtHrwM') as res, tryBase58Decode('invalid') as res_i
1136
1136
1137
1137
## base64Encode
1138
1138
1139
-
Encodes a String or FixedString as base64.
1139
+
Encodes a String or FixedString as base64, according to [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-4).
1140
1140
1141
1141
Alias: `TO_BASE64`.
1142
1142
1143
+
**Syntax**
1144
+
1145
+
```sql
1146
+
base64Encode(plaintext)
1147
+
```
1148
+
1149
+
**Arguments**
1150
+
1151
+
-`plaintext` — [String](../data-types/string.md) column or constant.
1152
+
1153
+
**Returned value**
1154
+
1155
+
- A string containing the encoded value of the argument.
1156
+
1157
+
**Example**
1158
+
1159
+
```sql
1160
+
SELECT base64Encode('clickhouse');
1161
+
```
1162
+
1163
+
Result:
1164
+
1165
+
```result
1166
+
┌─base64Encode('clickhouse')─┐
1167
+
│ Y2xpY2tob3VzZQ== │
1168
+
└────────────────────────────┘
1169
+
```
1170
+
1143
1171
## base64UrlEncode
1144
1172
1145
-
Encodes an URL (String or FixedString) as base64 according to [RFC 4648](https://tools.ietf.org/html/rfc4648).
1173
+
Encodes an URL (String or FixedString) as base64 with URL-specific modifications, according to [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-5).
1174
+
1175
+
**Syntax**
1176
+
1177
+
```sql
1178
+
base64UrlEncode(url)
1179
+
```
1180
+
1181
+
**Arguments**
1182
+
1183
+
-`url` — [String](../data-types/string.md) column or constant.
1184
+
1185
+
**Returned value**
1186
+
1187
+
- A string containing the encoded value of the argument.
Decodes a base64-encoded String or FixedString. Throws an exception in case of error.
1205
+
Accepts a String and decodes it from base64, according to [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-4). Throws an exception in case of an error.
1150
1206
1151
1207
Alias: `FROM_BASE64`.
1152
1208
1209
+
**Syntax**
1210
+
1211
+
```sql
1212
+
base64Decode(encoded)
1213
+
```
1214
+
1215
+
**Arguments**
1216
+
1217
+
-`encoded` — [String](../data-types/string.md) column or constant. If the string is not a valid Base64-encoded value, an exception is thrown.
1218
+
1219
+
**Returned value**
1220
+
1221
+
- A string containing the decoded value of the argument.
1222
+
1223
+
**Example**
1224
+
1225
+
```sql
1226
+
SELECT base64Decode('Y2xpY2tob3VzZQ==');
1227
+
```
1228
+
1229
+
Result:
1230
+
1231
+
```result
1232
+
┌─base64Decode('Y2xpY2tob3VzZQ==')─┐
1233
+
│ clickhouse │
1234
+
└──────────────────────────────────┘
1235
+
```
1236
+
1153
1237
## base64UrlDecode
1154
1238
1155
-
Decodes a base64-encoded URL (String or FixedString) according to [RFC 4648](https://tools.ietf.org/html/rfc4648). Throws an exception in case of error.
1239
+
Accepts a base64-encoded URL and decodes it from base64 with URL-specific modifications, according to [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-5). Throws an exception in case of an error.
1240
+
1241
+
**Syntax**
1242
+
1243
+
```sql
1244
+
base64UrlDecode(encodedUrl)
1245
+
```
1246
+
1247
+
**Arguments**
1248
+
1249
+
-`encodedUrl` — [String](../data-types/string.md) column or constant. If the string is not a valid Base64-encoded value with URL-specific modifications, an exception is thrown.
1250
+
1251
+
**Returned value**
1252
+
1253
+
- A string containing the decoded value of the argument.
Like `base64Decode` but returns an empty string in case of error.
1160
1272
1273
+
**Syntax**
1274
+
1275
+
```sql
1276
+
tryBase64Decode(encoded)
1277
+
```
1278
+
1279
+
**Arguments**
1280
+
1281
+
-`encoded`: [String](../data-types/string.md) column or constant. If the string is not a valid Base64-encoded value, returns an empty string.
1282
+
1283
+
**Returned value**
1284
+
1285
+
- A string containing the decoded value of the argument.
1286
+
1287
+
**Examples**
1288
+
1289
+
Query:
1290
+
1291
+
```sql
1292
+
SELECT tryBase64Decode('RW5jb2RlZA==') as res, tryBase64Decode('invalid') as res_invalid;
1293
+
```
1294
+
1295
+
```response
1296
+
┌─res────────┬─res_invalid─┐
1297
+
│ clickhouse │ │
1298
+
└────────────┴─────────────┘
1299
+
```
1300
+
1161
1301
## tryBase64UrlDecode
1162
1302
1163
1303
Like `base64UrlDecode` but returns an empty string in case of error.
1164
1304
1165
1305
**Syntax**
1166
1306
1167
1307
```sql
1168
-
tryBase64Decode(encoded)
1308
+
tryBase64UrlDecode(encodedUrl)
1169
1309
```
1170
1310
1171
1311
**Parameters**
1172
1312
1173
-
-`encoded`: [String](../data-types/string.md) column or constant. If the string is not a valid Base58-encoded value, returns an empty string in case of error.
1313
+
-`encodedUrl`: [String](../data-types/string.md) column or constant. If the string is not a valid Base64-encoded value with URL-specific modifications, returns an empty string.
1314
+
1315
+
**Returned value**
1316
+
1317
+
- A string containing the decoded value of the argument.
1174
1318
1175
1319
**Examples**
1176
1320
1177
1321
Query:
1178
1322
1179
1323
```sql
1180
-
SELECTtryBase64Decode('RW5jb2RlZA==') as res, tryBase64Decode('invalid') as res_invalid;
1324
+
SELECTtryBase64UrlDecode('aHR0cDovL2NsaWNraG91c2UuY29t') as res, tryBase64Decode('aHR0cHM6Ly9jbGlja') as res_invalid;
// Do symbol substitution as described in https://datatracker.ietf.org/doc/html/rfc4648#page-7
36
+
// Do symbol substitution as described in https://datatracker.ietf.org/doc/html/rfc4648#section-5
// Do symbol substitution as described in https://datatracker.ietf.org/doc/html/rfc4648#page-7
75
+
// Do symbol substitution as described in https://datatracker.ietf.org/doc/html/rfc4648#section-5
FunctionDocumentation::Description description = R"(Accepts a String and decodes it from base64, according to RFC 4648 (https://datatracker.ietf.org/doc/html/rfc4648#section-4). Throws an exception in case of an error. Alias: FROM_BASE64.)";
FunctionDocumentation::Arguments arguments = {{"encoded", "String column or constant. If the string is not a valid Base64-encoded value, an exception is thrown."}};
13
+
FunctionDocumentation::ReturnedValue returned_value = "A string containing the decoded value of the argument.";
FunctionDocumentation::Description description = R"(Encodes a String as base64, according to RFC 4648 (https://datatracker.ietf.org/doc/html/rfc4648#section-4). Alias: TO_BASE64.)";
FunctionDocumentation::Description description = R"(Accepts a base64-encoded URL and decodes it from base64 with URL-specific modifications, according to RFC 4648 (https://datatracker.ietf.org/doc/html/rfc4648#section-5).)";
FunctionDocumentation::Arguments arguments = {{"encodedUrl", "String column or constant. If the string is not a valid Base64-encoded value, an exception is thrown."}};
13
+
FunctionDocumentation::ReturnedValue returned_value = "A string containing the decoded value of the argument.";
FunctionDocumentation::Description description = R"(Encodes an URL (String or FixedString) as base64 with URL-specific modifications, according to RFC 4648 (https://datatracker.ietf.org/doc/html/rfc4648#section-5).)";
FunctionDocumentation::Description description = R"(Decodes a String or FixedString from base64, like base64Decode but returns an empty string in case of an error.)";
FunctionDocumentation::Arguments arguments = {{"encoded", "String column or constant. If the string is not a valid Base64-encoded value, returns an empty string."}};
13
+
FunctionDocumentation::ReturnedValue returned_value = "A string containing the decoded value of the argument.";
FunctionDocumentation::Description description = R"(Decodes an URL from base64, like base64UrlDecode but returns an empty string in case of an error.)";
FunctionDocumentation::Arguments arguments = {{"encodedUrl", "String column or constant. If the string is not a valid Base64-encoded value with URL-specific modifications, returns an empty string."}};
13
+
FunctionDocumentation::ReturnedValue returned_value = "A string containing the decoded value of the argument.";
0 commit comments