fastflowtransform.lineage¶
infer_sql_lineage ¶
infer_sql_lineage(rendered_sql, ref_map=None)
Infer column-level lineage for SQL
- CTE-aware (WITH ... AS (...))
- tracks simple transforms (lower/cast/trim/upper/etc.)
- expands CTE edges to base relations
- does NOT emit placeholder unknown edges; if ambiguous/unresolved -> no edge
Source code in src/fastflowtransform/lineage.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
parse_sql_lineage_overrides ¶
parse_sql_lineage_overrides(rendered_sql)
Parse inline overrides from SQL comments.
Supported
-- lineage: out_col <- relation.column -- lineage: out_col <- relation.column xform -- lineage: out_col <- relation.column, other_rel.other_col / lineage: out_col <- relation.column xform other <- rel.col /
Also supports JSON
-- lineage-json: {"out_col":[{"from_relation":"t","from_column":"c","transformed":true}]} / lineage-json: {...} /
Source code in src/fastflowtransform/lineage.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
merge_lineage ¶
merge_lineage(base, overlay)
Union-merge two lineage maps with dedupe.
Source code in src/fastflowtransform/lineage.py
119 120 121 122 123 124 125 126 127 128 129 130 131 | |
infer_py_lineage ¶
infer_py_lineage(py_source, ref_map=None)
Minimal python lineage
- If the file defines lineage = {...} or LINEAGE = {...}, we literal-eval it.
- Otherwise return {}.
This keeps python models supported without forcing heavy AST/dataframe analysis.
Source code in src/fastflowtransform/lineage.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |