tdfs4ds.lineage.indexing¶
tdfs4ds.lineage.indexing
¶
_PARTITION_STOPWORDS
module-attribute
¶
_PARTITION_STOPWORDS = {'range_n', 'case_n', 'columnar', 'case', 'between', 'and', 'or', 'not', 'is', 'null', 'no', 'range', 'in', 'like', 'exists', 'distinct', 'each', 'interval', 'day', 'month', 'year', 'from', 'to', 'every', 'cast', 'extract', 'coalesce', 'nullif', 'trim', 'substr', 'substring', 'current_date', 'current_timestamp', 'date', 'timestamp', 'integer', 'smallint', 'bigint', 'byteint', 'decimal', 'float', 'when', 'then', 'else', 'end', 'format', 'zone', 'as'}
_strip_sql_comments
¶
BUT do not treat comment markers inside single-quoted literals or double-quoted identifiers as comments.
_extract_parenthesized_list
¶
Given text and index pointing at an opening '(', return (content_inside_parens, index_after_closing_paren).
_split_top_level_commas
¶
Split by commas that are not inside parentheses.
_parse_partition_elements
¶
Parse a (masked) PARTITION BY expression into ordered levels. Each level: {level, kind, columns, raw}
_partitioning_by_column
¶
_mask_single_quoted_literals_same_len
¶
Replace each single-quoted literal with spaces of the same length so
- keywords inside literals can't be detected
- string length stays identical (indexes still align)
Handles escaped quotes like 'It''s'.
_find_create_table_columns_block_end
¶
Find index just after the closing ')' of the CREATE TABLE column-definition block. Robust: ignores parentheses inside single-quoted literals and double-quoted identifiers. Assumes ddl_clean is comment-stripped + whitespace-compressed.
analyze_teradata_ddl
¶
Analyse Teradata CREATE TABLE DDL and return
{ 'primary_index_columns': [...], 'partition_columns': [...], 'partitioning_levels': [...], 'partitioning_by_column': {...} }
Critical behavior: - Ignores keyword-like text inside single-quoted literals - Searches PRIMARY INDEX / PARTITION BY only in the table-options tail (after the column-definition block).
Remove Teradata-style comments