Repository navigation
ParseException due to ARRAY_AGG() and SAFE_CAST() #1622
Description
Activity
- changed the title
[-]ParseException due to ARRAY_AGG() and SAFE_CAST[/-][+]ParseException due to ARRAY_AGG() and SAFE_CAST()[/+]on Aug 24, 2022 manticore-projects commented
on Aug 24, 2022 ContributorMore actionsGreetings,
The problem is about
SAFE_CAST(x AS y), which is not a regular function but a special expression.
We will need to extend theCAST()expression accordingly.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,
TianqiHi @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 commented
on Sep 19, 2022 ContributorMore actions1. `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_aggCertainly, 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.- added a commit that references this issue
on Sep 19, 2022 @manticore-projects Thanks, I add
SAFE_CASTsupport and create a PR.- added a commit that references this issue
on Sep 20, 2022 Do I get this right, that this issue is not yet complete by the PR?
@wumpz Yes, It only solves
SAFE_CASTrelated problem,ARRAY_AGGis not included in this PR.Continued as Feature request under #1856
Hi,
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:
Was expecting one of:
The SQL statement looks like this:
select array_agg(safe_cast(n as Float64)) as temp from UNNEST(SPLIT("0,0,0,0,0",",")) as nWe are wondering is there a way to allow
ARRAY_AGG()andSAFE_CAST()without throwing exceptions?Thank you very much in advance,
Tianqi