Thalweg · API reference ← Main docs

Module identifiers

Module identifiers 

Source
Expand description

SQL identifier validation and quoting.

Two profile-aware validators:

  • is_valid_identifier - strict PostgreSQL: ASCII alnum + _, <= 63 chars, no leading digit. Use for column names emitted by schema inference / DDL generation and any name spliced into CREATE TABLE / binary COPY.
  • is_valid_identifier_with_hyphen - relaxed PG-safe: ASCII alnum + _ + -, <= 63 chars, no leading digit. Use for operator-supplied schema/table names where hyphens are valid elsewhere (e.g. Unity Catalog / Delta naming) but still need to be safe to splice into PG SQL after quote_identifier wraps the name.

Both should be paired with quote_identifier before emitting SQL - never splice a raw string. The validators reject Unicode alphanumerics on purpose: Postgres accepts UTF-8 in quoted identifiers, but Unicode confusables make injection auditing harder.

Functions§

is_valid_identifier
Validates a strict PostgreSQL identifier (schema/table/column name).
is_valid_identifier_with_hyphen
Validates a relaxed PostgreSQL identifier that also allows hyphens.
quote_identifier
Quotes and escapes a PostgreSQL identifier.