yggdrasil.databricks.sql¶
sql ¶
Databricks SQL helpers and engine wrappers.
safe_table_name ¶
Return name unchanged if it fits, otherwise truncate + hash.
Databricks Unity Catalog caps identifiers at 255 chars. When a caller
hands in something longer, split name on common separators (space,
underscore, dash), keep as many leading tokens as fit alongside a
BLAKE2b digest of the overflow tail, and join the result with _.
Tokens are kept whole — no chopping in the middle of a word — so
layer/role qualifiers (raw, brz, curated, dim, …)
stay readable at the front of the truncated name.
The result fits the limit, stays stable for the same input, and uses
only identifier-safe ASCII. None and empty strings pass through
unchanged so this stays safe to call before defaults have been
resolved.
is_glob_pattern ¶
Return True when value is a string carrying a * wildcard.
name_matcher ¶
Build a predicate for filtering resource names with optional globbing.
None→None(caller skips filtering entirely).- No
*→ exact-match predicate (case-sensitive). - Contains
*→ case-insensitive :func:fnmatch.fnmatchcasepredicate.
The predicate accepts None defensively and treats it as an empty name.
normalize_databricks_collation ¶
Normalize and validate a Databricks collation name.
Databricks supports the built-in UNICODE*, UTF8_BINARY*, and
UTF8_LCASE* families plus ICU locale collations with optional _CI,
_AI, and _RTRIM suffixes.
databricks_tag_literal ¶
Build a SQL string literal for Databricks tag DDL.
Tag keys and values can be annotated with an explicit collation to avoid dependence on the session or object default collation.
escape_sql_string ¶
Escape a Python string for safe embedding in a single-quoted SQL literal.
quote_ident ¶
Quote a SQL identifier using backticks, escaping embedded backticks.
quote_qualified_ident ¶
Backtick-quote each segment of a dotted identifier.
quote_principal ¶
Backtick-quote a Databricks principal name as a single identifier.
sql_literal ¶
Convert a Python value into a Databricks SQL literal string.