tdfs4ds.lineage.lineage¶
tdfs4ds.lineage.lineage
¶
_RE_CREATE_TABLE_AS
module-attribute
¶
_RE_CREATE_TABLE_AS = compile('\n \\bCREATE\\s+\n (?:MULTISET\\s+|SET\\s+|VOLATILE\\s+|TEMP(?:ORARY)?\\s+)? # qualifiers\n TABLE\\s+\n (?P<name>[\\w".@$#]+)\n \\s+AS\\s*\\( # <-- require AS (\n ', IGNORECASE | VERBOSE)
_RE_SINGLE_QUOTED_STRING
module-attribute
¶
_RE_SINGLE_QUOTED_STRING = compile("\n '\n (?:''|[^'])* # escaped quote or any non-quote char\n '\n ", VERBOSE | DOTALL)
_RE_REPLACE_VIEW_AS
module-attribute
¶
_RE_REPLACE_VIEW_AS = compile('\n \\bREPLACE\\s+VIEW\\s+\n (?P<name>[\\w".@$#]+)\n \\s+AS\\b\n ', IGNORECASE | VERBOSE)
_RE_CREATE_OR_REPLACE_VIEW_AS
module-attribute
¶
_RE_CREATE_OR_REPLACE_VIEW_AS = compile('\n \\b(?:CREATE|REPLACE)\\s+VIEW\\s+\n (?P<name>[\\w".@$#]+)\n \\s+AS\\b\n ', IGNORECASE | VERBOSE)
_RE_MERGE_INTO
module-attribute
¶
_RE_MERGE_INTO = compile('\n \\bMERGE\\s+INTO\\s+\n (?P<name>[\\w".@$#]+)\n \\b\n ', IGNORECASE | VERBOSE)
_RE_UPDATE
module-attribute
¶
_RE_UPDATE = compile('\n \\bUPDATE\\s+\n (?!SET\\b) # <-- prevents UPDATE SET from matching\n (?P<name>[\\w".@$#]+)\n \\b\n ', IGNORECASE | VERBOSE)
_RE_USING
module-attribute
¶
_RE_DELETE_FROM
module-attribute
¶
_RE_DELETE_FROM = compile('\n \\bDELETE\\s+FROM\\s+\n (?P<name>[\\w".@$#]+)\n \\b\n ', IGNORECASE | VERBOSE)
_RE_TD_ON_CLAUSE
module-attribute
¶
_RE_TD_ON_CLAUSE = compile('\n \\bON\\b\\s+\n (?P<arg>\n \\([^\\)]*\\) # naive: one-level parens (good enough for your test cases)\n |\n [\\w".@$#]+ # identifier\n )\n ', IGNORECASE | VERBOSE | DOTALL)
_RE_INSERT_INTO
module-attribute
¶
_RE_INSERT_INTO = compile('\n \\bINSERT\\s+INTO\\s+\n (?P<name>[\\w".@$#]+)\n \\b\n ', IGNORECASE | VERBOSE)
_RE_CREATE_VIEW_AS
module-attribute
¶
_RE_CREATE_VIEW_AS = compile('\n \\b(?:CREATE|REPLACE)\\s+VIEW\\s+\n (?P<name>[\\w".@$#]+)\n \\s+AS\\b\n ', IGNORECASE | VERBOSE)
_RE_FROM_JOIN
module-attribute
¶
_RE_FROM_JOIN = compile('\n \\bFROM\\b\n \\s+(?P<name>[\\w".@$#]+)\n |\n \\b(?:INNER\\s+JOIN|LEFT\\s+JOIN|RIGHT\\s+JOIN|FULL\\s+OUTER\\s+JOIN|CROSS\\s+JOIN|JOIN)\\b\n \\s+(?P<join_name>[\\w".@$#]+)\n ', IGNORECASE | VERBOSE)
_RE_CTE_NAMES
module-attribute
¶
_RE_CTE_NAMES = compile('\n \\bWITH\\b\\s*(?P<first>\\w+)\\s+AS\\s*\\(\n |,\\s*(?P<next>\\w+)\\s+AS\\s*\\(\n ', IGNORECASE | VERBOSE)
_RE_EXTRACT_FROM
module-attribute
¶
_RE_USING_TABLE
module-attribute
¶
_RE_SPEC_TABLE_NAME
module-attribute
¶
_RE_SPEC_TABLE_NAME = compile('\\b(?:SERIES_SPEC|ART_SPEC)\\s*\\(.*?\\bTABLE_NAME\\s*\\(\\s*([^)\\s,]+)\\s*\\)', IGNORECASE | DOTALL)
_RE_TD_FUNC_CALL
module-attribute
¶
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
_mask_single_quoted_strings
¶
Replace all single-quoted SQL string literals with empty string ''. Preserves SQL structure while removing misleading keywords.
_extract_series_art_table_names
¶
Extract the table/view names referenced inside SERIES_SPEC(TABLE_NAME(...)) /
ART_SPEC(TABLE_NAME(...)) clauses of a UAF EXECUTE FUNCTION statement.
Inert on ordinary SQL (SERIES_SPEC/ART_SPEC do not appear in normal views), so
wiring it into analyze_sql_query adds no spurious sources for non-UAF views.
_extract_balanced_parens
¶
Return the substring starting at open_paren_index (which must point to '(') up to and including the matching closing ')'. Falls back to end-of-string if unbalanced.
analyze_sql_query
¶
Extracts source and target tables/views from a SQL query.