google / zetasql

ZetaSQL - Analyzer Framework for SQL
Apache License 2.0
2.28k stars 214 forks source link

QUALIFY clause without WHERE, GROUP BY or HAVING #115

Closed pgrivachev closed 2 years ago

pgrivachev commented 2 years ago

I found that in BigQuery it is possible to use QUALIFY clause without WHERE or GROUP BY or HAVING clause.

But when I try to analyze the same query using ZetaSQL it returns the error:

"QUALIFY clause must be used in conjunction with WHERE or GROUP BY or HAVING clause"

Is it a limitation or bug in ZetaSQL?

image

matthewcbrown commented 2 years ago

QUALIFY is a weird one, since it has some backwards compatibility issues. You must both enable the language feature: FEATURE_V_1_3_QUALIFY

But also set "QUALIFY" as a reserved keyword: c++: https://github.com/google/zetasql/blob/1933acefe8eb10e293309a9fa7d7c7f1cb6bf8c4/zetasql/public/language_options.h#L273

java: <uh...I guess you can't do this from java right now?! >

pgrivachev commented 2 years ago

Thank you @matthewcbrown, adding "QUALIFY" to reserved keywords helped.