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

BigQuery Dialect - Qualify Usage Issue #124

Open
jrbangit opened this issue Nov 28, 2022 · 3 comments
Open

BigQuery Dialect - Qualify Usage Issue #124

jrbangit opened this issue Nov 28, 2022 · 3 comments

Comments

@jrbangit
Copy link

I am using ZetaSQL to parse queries executed from BigQuery. I came across this scenario.
Apparently, in BigQuery, when you use the QUALIFY function, whether you use it with or without a where clause, it is gonna push through. However, if you parse that query in ZetaSQL and the query utilizes QUALIFY function without the WHERE clause, it's gonna fail to parse it.

com.google.zetasql.io.grpc.StatusRuntimeException: INVALID_ARGUMENT: QUALIFY clause must be used in conjunction with WHERE or GROUP BY or HAVING clause

is this an expected scenario? which in case of BigQuery dialect, we will have to create a work around or adding WHERE 1=1 or something? just to add context, the queries we are parsing are from audit logs.

sample query:

CREATE OR REPLACE TABLE
  `test_project`.`test_dataset`.`test_target_table`
PARTITION BY
  TIMESTAMP_TRUNC(test_datetime, day) AS (
  WITH
    test AS (
    SELECT
      *
    FROM
      `test_project`.`test_dataset`.`test_source_table`
    QUALIFY ROW_NUMBER() OVER(PARTITION BY test_col1, test_col2 ORDER BY test_datetime ASC) = 1 )
  SELECT
    *
  FROM
    test );
@pgrivachev
Copy link

Here is something that can help: #115.

@jrbangit
Copy link
Author

thank you for the response @pgrivachev - I forgot to mention, I already had this enabled ZetaSQLOptions.LanguageFeature.FEATURE_V_1_3_QUALIFY). However, as for the second part, I'm not quite sure how do we add reserved keywords for java?

@sridivakar
Copy link

@jrbangit , you can try this way :

languageOptions.enableReservableKeyword("QUALIFY");

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

No branches or pull requests

3 participants