reata / sqllineage

SQL Lineage Analysis Tool powered by Python
MIT License
1.19k stars 215 forks source link

Tsql -UPDATE set analyz error #592

Open tianlulalala opened 3 months ago

tianlulalala commented 3 months ago

from sqllineage.runner import LineageRunner sql = """ UPDATE a SET a.ClaimReason=b.claimreason FROM table1 as a INNER JOIN table2 b ON a.AccountID=b.AccountID AND a.Product=b.Product WHERE a.ClaimReason='NULL'; """

res=LineageRunner(sql, dialect="tsql").print_table_lineage()

image

correct: TARGERT_TABLE :.table1

sqlineage version :1.15.1

reata commented 3 months ago

This is very unconventional for tsql to allow table alias to be followed after UPDATE keyword. Ref: https://learn.microsoft.com/en-us/sql/t-sql/queries/update-transact-sql?view=sql-server-ver16

PostgreSQL and MySQL all require table name after UPDATE. Need to do more research on dialect supports.