You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ParseException due to ARRAY_AGG() and SAFE_CAST() #1622
We recently found this ParseException due to the use of ARRAY_AGG() and SAFE_CAST() from the built-in functions provided by Google BigQuery. However, when I tried to validate the SQL syntax, I got this error:
ParseException: Cannot parse statement: Encountered unexpected token: "(" "(" at line 1, column 17.
The problem is about SAFE_CAST(x AS y), which is not a regular function but a special expression.
We will need to extend the CAST() expression accordingly.
Thanks a lot for quickly identifying the root cause of the problem. Just would like to follow up with you and see when approximately will this change be applied / released? Any details would be greatly appreciated.
1. `ARRAY_AGG(x LMIT 10)`
2. `ARRAY_AGG( x IGNORE NULLS ORDER BY x)`
3. `ARRAY_AGG( DISTINCT x)`
Google ARRAY_AGG references: https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#array_agg
Certainly, because all of those are mot standard compliant, but Google BigQuery specific.
You will need to sponsor or provide an implementation for such special function parameters.
Activity
[-]ParseException due to ARRAY_AGG() and SAFE_CAST[/-][+]ParseException due to ARRAY_AGG() and SAFE_CAST()[/+]manticore-projects commentedon Aug 24, 2022
Greetings,
The problem is about
SAFE_CAST(x AS y), which is not a regular function but a special expression.We will need to extend the
CAST()expression accordingly.Tianqi1006 commentedon Aug 25, 2022
Greetings,
Thanks a lot for quickly identifying the root cause of the problem. Just would like to follow up with you and see when approximately will this change be applied / released? Any details would be greatly appreciated.
Best regards,
Tianqi
dequn commentedon Sep 19, 2022
Hi @manticore-projects , not only
SAFE_CAST, but alsoARRAY_AGGcan not be fully correctly parsed.failed cases:
ARRAY_AGG(x LMIT 10)ARRAY_AGG( x IGNORE NULLS ORDER BY x)ARRAY_AGG( DISTINCT x)Google ARRAY_AGG references: https://cloud.google.com/bigquery/docs/reference/standard-sql/aggregate_functions#array_agg
JsqlParser Version: 4.5
manticore-projects commentedon Sep 19, 2022
Certainly, because all of those are mot standard compliant, but Google BigQuery specific.
You will need to sponsor or provide an implementation for such special function parameters.
Support BigQuery SAFE_CAST (JSQLParser#1622)
dequn commentedon Sep 19, 2022
@manticore-projects Thanks, I add
SAFE_CASTsupport and create a PR.Support BigQuery SAFE_CAST (#1622) (#1634)
wumpz commentedon Sep 20, 2022
Do I get this right, that this issue is not yet complete by the PR?
dequn commentedon Sep 21, 2022
@wumpz Yes, It only solves
SAFE_CASTrelated problem,ARRAY_AGGis not included in this PR.manticore-projects commentedon Sep 2, 2023
Continued as Feature request under #1856