simple-ddl-parser icon indicating copy to clipboard operation
simple-ddl-parser copied to clipboard

Parser fail in Bigquery partition with RANGE_BUCKET and GENERATE_ARRAY

Open lmarqueto opened this issue 2 years ago • 2 comments

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

lmarqueto avatar Jan 09 '23 19:01 lmarqueto

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!

xnuinside avatar Jan 10 '23 07:01 xnuinside

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

lmarqueto avatar Jan 10 '23 11:01 lmarqueto

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

xnuinside avatar May 11 '24 16:05 xnuinside