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

Invalid testcases #211

Open
apstndb opened this issue Nov 23, 2024 · 0 comments
Open

Invalid testcases #211

apstndb opened this issue Nov 23, 2024 · 0 comments

Comments

@apstndb
Copy link
Contributor

apstndb commented Nov 23, 2024

There are invalid GoogleSQL in testdata.

$ for filename in testdata/input/query/*.sql; do docker run --rm --platform linux/amd64 zetasql_ubuntu execute_query --product_mode=external --mode parse,unparse -- "$(cat ${filename})"; done > zetasql_log.txt
Syntax error: Expected "@" or "@@" or integer literal but got floating point literal "0.1" [at 2:36]
from x tablesample BERNOULLI (cast(0.1 as float64) percent),
                                   ^

Error on real instance

spanner> EXPLAIN
         select cast(1 as INT64), cast(0.1 as float32), cast((struct(), 1, [2, 3], ["4", "5"]) as struct<struct<>, x int64, y array<int64>, z array<string>>)
         from x tablesample BERNOULLI (cast(0.1 as float64) percent),
              y tablesample BERNOULLI (cast(1 as int64) rows),
              z tablesample BERNOULLI (cast(@param as int64) rows)
         limit cast(1 as INT64) offset cast(@foo as INT64);
ERROR: spanner: code = "InvalidArgument", desc = "Syntax error: Expected \\\"@\\\" or \\\"@@\\\" or integer literal but got floating point literal \\\"0.1\\\" [at 2:36]\\nfrom x tablesample BERNOULLI (cast(0.1 as float64) percent),\\n                                   ^"
spanner> SELECT
      ->   *
      -> FROM
      ->   Singers A
      ->   HASH JOIN
      ->   Singers B
      ->   ON A.SingerID = B.SingerID
      ->   APPLY JOIN
      ->   Singer C
      ->   ON B.SingerID = C.SingerID
      ->   LOOP JOIN
      ->   Singer D
      ->   ON C.SingerID = D.SingerID
      -> ;
ERROR: spanner: code = "InvalidArgument", desc = "Syntax error: Expected end of input but got identifier \"APPLY\" [at 8:3]\n  APPLY JOIN\n  ^"

Although these are valid values ​​for the JOIN_METHOD hint, I don't think they are valid prefixes for JOIN, at least in the current implementation.

https://github.com/google/zetasql/blob/a516c6b26d183efc4f56293256bba92e243b7a61/zetasql/parser/zetasql.tm#L7713-L7718

I am doubting that APPLY JOIN has never been syntax, but table_name APPLY JOIN becomes valid because:

SELECT * FROM Singers APPLY JOIN Albums USING (SingerId);

It is valid query because it is interpreted as

SELECT * FROM Singers AS APPLY JOIN Albums USING (SingerId);
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

1 participant