starlake-ai / jsqltranspiler

Rewrite BigQuery, Redshift, Snowflake and Databricks queries into DuckDB compatible SQL (with deep transformation of functions, data types and format characters) using Java.
https://starlake.ai/starlake/
Other
28 stars 3 forks source link

Unsupported select as struct or value in BigQuery #12

Closed tiboun closed 4 months ago

tiboun commented 4 months ago

Given the following queries

SELECT ARRAY(SELECT AS STRUCT 1 a, 2 b)
SELECT AS VALUE STRUCT(1 AS a, 2 AS b) xyz

We may be translated them respectively to :

SELECT array_value({'a': 1, 'b': 2});

and

SELECT {'a': 1, 'b': 2} AS xyz

A more complex version of the first query would be

SELECT ARRAY(SELECT AS STRUCT 1 a, 2 b union all SELECT AS STRUCT 3 a, 4 b)

which get translated into

SELECT array_value({'a': 1, 'b': 2}, {'a': 3, 'b': 4});
manticore-projects commented 4 months ago

Fixed via d5352cfd8214e8a70e14ffec4cce7332bfafb218 though it depends on cutting edge JSQLParser version.