xnuinside / simple-ddl-parser

Simple DDL Parser to parse SQL (HQL, TSQL, AWS Redshift, BigQuery, Snowflake and other dialects) ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc. & table properties, types, domains, etc.
MIT License
175 stars 40 forks source link

Snowflake dialect missing Insert and Delete values #270

Open HalfonA opened 2 weeks ago

HalfonA commented 2 weeks ago

Describe the bug Hi, I parse some logs of queries and I stumbled upon this bug: When using the parser with snowflake dialect, select and create works fine, but delete and insert returns empty lists- meaning no tables detected.

To Reproduce Steps to reproduce the behavior:

In [11]: ddl = """INSERT INTO TDM . CLEANSED . I_TRACKING (ID, BATCH_SIZE, SOURCE, SNOWFLAKE_BATCH_COMMIT_TS, BATCH_MIN_SOURCE_TS, BATCH_MAX_SOURCE_TS, MIN_OFFSET, MAX_OFFSET, K_PARTITION, IR, DUP_K_DROPS, TABLE_NAME ) VALUES ( ? )"""

In [12]: DDLParser(ddl).run(output_mode="snowflake")
Out[12]: []
In [15]: ddl =  """DELETE FROM SL_CHANGE WHERE A_CHANGE_ID = ?"""

In [16]: DDLParser(ddl).run(output_mode="snowflake")
Out[16]: []

Expected behavior I expect for the insert case, to have TDM.CLEANSED.I_TRACKING as a table, containing these columns: ID, BATCH_SIZE, SOURCE, SNOWFLAKE_BATCH_COMMIT_TS, BATCH_MIN_SOURCE_TS, BATCH_MAX_SOURCE_TS, MIN_OFFSET, MAX_OFFSET, K_PARTITION, IR, DUP_K_DROPS, TABLE_NAME as a dict

for the delete case the same thing - SL_CHANGE as the table_name and A_CHANGE_ID as the column

Desktop:

Additional context I tried changing the ? for another value but it didn't make any change for the insert ddl specifically, I also tried removing the spaces in the table name but it didn't make any change either

xnuinside commented 2 days ago

@HalfonA, hi, thanks for opening the issue, problem, that insert & delete is not supported. Also, DELETE & INSERT is not a part of DDL - it is a DML, so DML is not supported at all. It was not planned to add any support for DML (because of idea & naming of the package).