Skip to content
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

fix(bigquery)!: Canonicalize struct & array inline constructor #3751

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

VaggelisD
Copy link
Collaborator

Public slack context

BigQuery allows Array/Struct inline construction such as:

SELECT 
   STRUCT<a INT, b STRING>(1, 'foo'),
   ARRAY<INT>[1, 2, 3], 
   ...

Up until now this was parsed as a single exp.DataType node with the inlined values stored in it's values arg. However, this is (1) semantically incorrect as exp.DataType should only encode type information and (2) it doesn't facilitate transpilation in any way.

This PR aims to decouple the actual values from exp.DataType and enable seamless transpilation (mainly focused towards DDB) by canonicalizing such expressions to CAST(<values> AS <type>).

This is done by transforming the parsed exp.DataType into an exp.Cast, with the values now stored in an exp.Array / exp.Struct as the cast's LHS and the type as the RHS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants