taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
798 stars 180 forks source link

Parsing fails for some data types ( SNOWFLAKE ) #1912

Closed create-new-entity closed 4 months ago

create-new-entity commented 4 months ago

Describe the bug

For the Snowflake database engine, the supported data types do not match with their documented ones.

We are using the library to convert DDLs into ASTs, and having this support is important to us.

Missing datatypes: NUMERIC(3,3), BYTEINT, BINARY, VARBINARY, GEOGRAPHY, TIMESTAMP_TZ.

Please see Snowflake numeric types documentation for details.

Database Engine Snowflake

To Reproduce Here is a sample create query that is correct according to the snowflake documentation:

create TABLE TEST_SNOWFLAKE ( "att1" NUMERIC(3,3), "att2" BYTEINT, "att3_SAMPLE_3" BINARY, "att4_SAMPLE_4" VARBINARY, "att5_SAMPLE_5" GEOGRAPHY, "att6_SAMPLE_6" TIMESTAMP_TZ, primary key ("att1") );

The library fails to generate AST for this sample.

Library version 4.18.0 with Node 20.11.1 is used in our application and we are building the library with 16.20.2.

Expected behavior

Expected behavior is that the given create table statement goes through so we can get the AST-tree of the query with the library. It contains the specified data types matching Snowflake specifications.

Additional context For the query, error looks like this: failing_output.txt