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
179 stars 40 forks source link

Parser fail in Bigquery partition with RANGE_BUCKET and GENERATE_ARRAY #183

Closed lmarqueto closed 4 months ago

lmarqueto commented 1 year ago

Describe the bug In the Bigquery if use RANGE_BUCKET with GENERATE_ARRAY in partition the parser fail

To Reproduce This fail

CREATE TABLE data.test(
    field_a INT OPTIONS(description='some description')
)
PARTITION BY RANGE_BUCKET(field_a, GENERATE_ARRAY(10, 1000, 1));

This work

CREATE TABLE data.test(
   field_a INT OPTIONS(description='some description')
 )
 PARTITION BY RANGE_BUCKET(field_a, [1,2,3]]) ;

Expected behavior Parser work in both cases

xnuinside commented 1 year ago

I think problem in that in partition by does not supported yet functions, only columns lists, I will add support for that @lmarqueto and again thanks for opening the issue!

lmarqueto commented 1 year ago

I did some tests and with only one functions it's work fine, eg:

PARTITION BY DATE_TRUNC(field, MONTH) PARTITION BY DATE(field) PARTITION BY RANGE_BUCKET(field, [1,2,3]])

But if put a function inside a another function, the parser fail

xnuinside commented 4 months ago

Finally released support in version 1.3.0. Tests: https://github.com/xnuinside/simple-ddl-parser/blob/main/tests/dialects/test_bigquery.py#L881 Sorry for ignoring this issue too long If will be needed anything else - feel free to open new issue