-
Notifications
You must be signed in to change notification settings - Fork 606
Support Struct datatype parsing for GenericDialect #1241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Struct datatype parsing for GenericDialect #1241
Conversation
@@ -350,7 +350,7 @@ fn parse_create_table_with_options() { | |||
#[test] | |||
fn parse_nested_data_types() { | |||
let sql = "CREATE TABLE table (x STRUCT<a ARRAY<INT64>, b BYTES(42)>, y ARRAY<STRUCT<INT64>>)"; | |||
match bigquery().one_statement_parses_to(sql, sql) { | |||
match bigquery_and_generic().one_statement_parses_to(sql, sql) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also test for generic dialect
@@ -632,12 +638,12 @@ fn parse_typed_struct_syntax() { | |||
expr_from_projection(&select.projection[1]) | |||
); | |||
|
|||
let sql = r#"SELECT STRUCT<DATE>("2011-05-05"), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; | |||
let select = bigquery().verified_only_select(sql); | |||
let sql = r#"SELECT STRUCT<DATE>('2011-05-05'), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change " to ', so it is also understandable by generic dialect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than updating the existing test, can you please keep the existing test (that uses "
) and add new coverage for bigquery_and_generic dialect (with the '
)?
This is to avoid losing existing test coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added extra test, was thinking of using a scenario struct to reuse the query logic and just replacing " with ' in the middle before invoking the parser, but i guess a bit boilerplating is easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thank you -- I know it is a lot of repetition but it is easier to understand I think. Thank you 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contirbution @duongcongtoai -- the code in this PR looks great to me. I think we need to avoid changing the existing tests, but then this PR wll be good to go
@@ -632,12 +638,12 @@ fn parse_typed_struct_syntax() { | |||
expr_from_projection(&select.projection[1]) | |||
); | |||
|
|||
let sql = r#"SELECT STRUCT<DATE>("2011-05-05"), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; | |||
let select = bigquery().verified_only_select(sql); | |||
let sql = r#"SELECT STRUCT<DATE>('2011-05-05'), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than updating the existing test, can you please keep the existing test (that uses "
) and add new coverage for bigquery_and_generic dialect (with the '
)?
This is to avoid losing existing test coverage
Pull Request Test Coverage Report for Build 8900428855Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @duongcongtoai -- looks great to me
@@ -632,12 +638,12 @@ fn parse_typed_struct_syntax() { | |||
expr_from_projection(&select.projection[1]) | |||
); | |||
|
|||
let sql = r#"SELECT STRUCT<DATE>("2011-05-05"), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; | |||
let select = bigquery().verified_only_select(sql); | |||
let sql = r#"SELECT STRUCT<DATE>('2011-05-05'), STRUCT<DATETIME>(DATETIME '1999-01-01 01:23:34.45'), STRUCT<FLOAT64>(5.0), STRUCT<INT64>(1)"#; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thank you -- I know it is a lot of repetition but it is easier to understand I think. Thank you 🙏
Fix #1240