Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.66 KB

File metadata and controls

64 lines (48 loc) · 1.66 KB
description
This section contains reference documentation for base64 encode and decode functions.

Base64

Encoding scheme follows java.util.Base64.Encoder

  • toBase64 returns Base64 encoded string of input binary data (bytes type).
  • fromBase64 returns binary data (represented as a Hex string) from Base64-encoded string.

Signature

toBase64(bytesCol)

fromBase64(stringCol)

Usage Examples

{% hint style="info" %} For better readability, the following examples converts string hello! into BYTES using toUtf8 function and converts the decoded BYTES into string using fromUtf8. {% endhint %}

SELECT toBase64(toUtf8('hello!')) AS encoded
FROM ignoreMe
encoded
aGVsbG8h
SELECT fromUtf8(fromBase64('aGVsbG8h')) AS decoded
FROM ignoreMe
decoded
hello!

{% hint style="info" %} Note that without UTF8 string conversion, returned BYTES will be represented as a Hex string following Pinot's BYTES column representation. See the example below. {% endhint %}

SELECT fromBase64('aGVsbG8h') AS decoded
FROM ignoreMe
decoded
68656c6c6f21

{% hint style="warning" %} Note that the following query will throw compilation error as string is not a valid input type for toBase64. {% endhint %}

SELECT toBase64('hello!') AS encoded
FROM ignoreMe