You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is related to #384 and #159. It's common (although frustrating) practice to exclude semicolons in TSQL queries. For example:
-- sample_query.sqlSELECT CUST_ID, CUST_NAME, CUST_CITY, CUST_COUNTRY
INTO #TEMP_CUSTOMERSFROM T_CUSTOMERS
WHERE CUST_COUNTRY ='USA'SELECT CUST.*
, SALES.CUM_SALES
INTO #TEMP_FINAL_RESULTSFROM#TEMP_CUSTOMERS CUST AS CUSTLEFT JOIN T_SALES AS SALES
ONCUST.CUST_ID=SALES.CUST_IDWHERESALES.CUST_ID IS NULLSELECT*FROM#TEMP_FINAL_RESULTS
This causes the LineageRunner() to parse the first statement and skip the remaining statements.
fromsqllineage.runnerimportLineageRunnerimportcsvimportpandasaspd# read text from sample_query.sqlsql_script=open('sample_query.sql', 'r').read()
# parse sql_script with LineageRunnerparsed_results=LineageRunner(sql_script, dialect="tsql")
# write parsed_results to data framedf=pd.DataFrame(parsed_results.get_column_lineage())
df.columns= ['Source', 'Target']
print(df)
The output is:
Source
Target
<default>.t_customers.cust_city
<default>.#temp_customers.cust_city
<default>.t_customers.cust_country
<default>.#temp_customers.cust_country
<default>.t_customers.cust_id
<default>.#temp_customers.cust_id
<default>.t_customers.cust_name
<default>.#temp_customers.cust_name
The proposal is to return a warning message when dialect='tsql':
parsed_results=LineageRunner(sql_script, dialect="tsql")
"""Warning: No semicolons detected. Consider adding a semicolon after each statement."""
The text was updated successfully, but these errors were encountered:
The issue is related to #384 and #159. It's common (although frustrating) practice to exclude semicolons in TSQL queries. For example:
This causes the
LineageRunner()
to parse the first statement and skip the remaining statements.The output is:
<default>.t_customers.cust_city
<default>.#temp_customers.cust_city
<default>.t_customers.cust_country
<default>.#temp_customers.cust_country
<default>.t_customers.cust_id
<default>.#temp_customers.cust_id
<default>.t_customers.cust_name
<default>.#temp_customers.cust_name
The proposal is to return a warning message when
dialect='tsql'
:The text was updated successfully, but these errors were encountered: