Decode directive

The DECODE directive decodes a column value as one of base32base64, hex, or url following RFC-4648.

Syntax

decode <base32|base64|hex> :column

The syntax for decoding a column as url is:

url-decode :column

The :column is the name of the column to which the decoding is applied.

Usage Notes

Base decoding of data is used in many situations to store or transfer data in environments that, for legacy reasons, are restricted to US-ASCII data. Base decoding can be used in new applications that do not have legacy restrictions because it allows the manipulation of objects with text editors.

The DECODE directive generates a new column with a name following the format of <column>_decode_<type>.

Different column values are handled following these rules:

  • If the column is null, the resulting column will also be null.

  • If the column specified is not found in the record, then the record is skipped as a no-op.

  • If the column value is not of either type string or byte array, it fails.

See also the ENCODE directive.

Example

Using this record as an example:

{ "col1": "IJQXGZJTGIQEK3TDN5SGS3TH", "col2": "VGVzdGluZyBCYXNlIDY0IEVuY29kaW5n", "col3": "48657820456e636f64696e67" "col4": "Mr.+Owen+Harris+Braund" }

Applying these directives:

results in this record:

 

Created in 2020 by Google Inc.