decode()

Converts blob to VARCHAR. Invalid UTF-8 is handled based on the error behavior argument. Can be 'strict' (default, fail), 'replace' to replace invalid characters with '?', or 'ignore' to skip invalid characters.

Reference: DuckDB 2.0.0

Arguments & returns

2 overloads

decode(blob)

Scalar
Overload link blob Returns
#01 BLOB VARCHAR

decode(blob, error_option)

Scalar
Overload link bloberror_option Returns
#02 BLOBVARCHAR VARCHAR
decode example
SQL
Haybarn WASM 2.0.0-rc12 Β· In your browser

Engine example Β· Run to view results.

More examples

decode example 2
SQL
Haybarn WASM 2.0.0-rc12 Β· In your browser

Engine example Β· Run to view results.

decode example 3
SQL
Haybarn WASM 2.0.0-rc12 Β· In your browser

Engine example Β· Run to view results.

In other engines

Apache Sparkdecode()

DECODE(x, 'utf-8')
In DuckDB
DECODE(x)

SQLGlot example β†—

Prestofrom_utf8()

FROM_UTF8(x)
In DuckDB
DECODE(x)

SQLGlot example β†—

Snowflakebase64_decode_string()

SELECT BASE64_DECODE_STRING('U25vd2ZsYWtl')
In DuckDB
SELECT DECODE(FROM_BASE64('U25vd2ZsYWtl'))

SQLGlot example β†—