Skip to content

docs: missing documentation for HEX_ENCODE, HEX_DECODE_BINARY, TRY_HEX_DECODE_BINARY, BASE64_ENCODE, BASE64_DECODE_BINARY, and TRY_BASE64_DECODE_BINARY binary aliases #3294

@sundy-li

Description

@sundy-li

What's Missing

Six binary-typed function aliases registered in the Databend function registry have no documentation:

Alias Primary function Input → Output
HEX_ENCODE TO_HEX BINARY → STRING
HEX_DECODE_BINARY FROM_HEX STRING → BINARY
TRY_HEX_DECODE_BINARY TRY_FROM_HEX STRING → BINARY (NULL on error)
BASE64_ENCODE TO_BASE64 BINARY → STRING
BASE64_DECODE_BINARY FROM_BASE64 STRING → BINARY
TRY_BASE64_DECODE_BINARY TRY_FROM_BASE64 STRING → BINARY (NULL on error)

Source File

/workspace/databend/src/query/functions/src/scalars/binary.rs

Relevant registrations:

.scalar_builder("to_hex")
    .aliases(&["hex", "hex_encode"])   // hex_encode: BINARY → STRING

.scalar_builder("from_hex")
    .aliases(&["unhex", "hex_decode_binary"])   // hex_decode_binary: STRING → BINARY

registry.register_aliases("try_from_hex", &["try_hex_decode_binary"]);

.scalar_builder("to_base64")
    .aliases(&["base64_encode"])   // base64_encode: BINARY → STRING

.scalar_builder("from_base64")
    .aliases(&["base64_decode_binary"])   // base64_decode_binary: STRING → BINARY

registry.register_aliases("try_from_base64", &["try_base64_decode_binary"]);

What They Do

These are binary-typed overloads of the existing hex/base64 string functions. The key distinction from the string variants (HEX, UNHEX, TO_BASE64, FROM_BASE64) is that these aliases operate on or return the BINARY data type rather than STRING, making them useful when working with raw binary data.

  • HEX_ENCODE(binary) — hex-encodes a BINARY value to a hex STRING
  • HEX_DECODE_BINARY(string) — decodes a hex STRING to BINARY; throws on invalid input
  • TRY_HEX_DECODE_BINARY(string) — same as above but returns NULL on error
  • BASE64_ENCODE(binary) — base64-encodes a BINARY value to a STRING
  • BASE64_DECODE_BINARY(string) — decodes a base64 STRING to BINARY; throws on invalid input
  • TRY_BASE64_DECODE_BINARY(string) — same as above but returns NULL on error

Suggested Doc Location

These aliases should be mentioned in the existing docs for their primary functions:

  • HEX_ENCODE/docs/en/sql-reference/20-sql-functions/06-string-functions/hex.md or the conversion to-hex.md
  • HEX_DECODE_BINARY / TRY_HEX_DECODE_BINARY/docs/en/sql-reference/20-sql-functions/06-string-functions/from-hex.md
  • BASE64_ENCODE/docs/en/sql-reference/20-sql-functions/06-string-functions/to-base64.md
  • BASE64_DECODE_BINARY / TRY_BASE64_DECODE_BINARY/docs/en/sql-reference/20-sql-functions/06-string-functions/from-base64.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions