arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Base64

This section contains reference documentation for base64 encode and decode functions.

Encoding scheme follows java.util.Base64.Encoderarrow-up-right

  • toBase64 returns Base64 encoded string of input binary data (bytes type).

  • fromBase64 returns binary data (represented as a Hex string) from Base64-encoded string.

hashtag
Signature

toBase64(bytesCol)

fromBase64(stringCol)

hashtag
Usage Examples

circle-info

For better readability, the following examples converts string hello! into BYTES using function and converts the decoded BYTES into string using .

encoded
decoded
circle-info

Note that without UTF8 string conversion, returned BYTES will be represented as a Hex string following Pinot's . See the example below.

decoded
circle-exclamation

Note that the following query will throw compilation error as string is not a valid input type for toBase64.

aGVsbG8h

hello!

68656c6c6f21

toUtf8arrow-up-right
fromUtf8arrow-up-right
BYTES column representationarrow-up-right
SELECT toBase64(toUtf8('hello!')) AS encoded
FROM ignoreMe
SELECT fromUtf8(fromBase64('aGVsbG8h')) AS decoded
FROM ignoreMe
SELECT fromBase64('aGVsbG8h') AS decoded
FROM ignoreMe
SELECT toBase64('hello!') AS encoded
FROM ignoreMe