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

Support EXCEPT and REPLACE in SelectItem #184

Open
apstndb opened this issue Oct 27, 2024 · 0 comments
Open

Support EXCEPT and REPLACE in SelectItem #184

apstndb opened this issue Oct 27, 2024 · 0 comments

Comments

@apstndb
Copy link
Contributor

apstndb commented Oct 27, 2024

select_all:
  [ expression. ]*
  [ EXCEPT ( column_name [, ...] ) ]
  [ REPLACE ( expression [ AS ] column_name [, ...] ) ]

EXCEPT

https://cloud.google.com/spanner/docs/reference/standard-sql/query-syntax#select_except

$ go run ./tools/parse --mode query "SELECT * EXCEPT (n) FROM (SELECT 1 AS n, "foo" AS s)"                    
2024/10/28 00:12:11 syntax error: :1:17: expected token: ALL, DISTINCT, but: (

  1:  SELECT * EXCEPT (n) FROM (SELECT 1 AS n, foo AS s)

REPLACE

https://cloud.google.com/spanner/docs/reference/standard-sql/query-syntax#select_replace

$ go run ./tools/parse --mode query "SELECT * REPLACE (2 AS n) FROM (SELECT 1 AS n, "foo" AS s)"
2024/10/28 00:12:44 syntax error: :1:10: expected token: <eof>, but: <ident>

  1:  SELECT * REPLACE (2 AS n) FROM (SELECT 1 AS n, foo AS s)
               ^~~~~~~

Note:

Official syntax docs says AS is optional, but actually AS can't be omitted

spanner> SELECT * REPLACE (2 n) FROM (SELECT 1 AS n, "foo" AS s);
ERROR: spanner: code = "InvalidArgument", desc = "Syntax error: Expected keyword AS but got identifier \\\"n\\\" [at 1:21]\\nSELECT * REPLACE (2 n) FROM (SELECT 1 AS n, \\\"foo\\\" AS s)\\n                    ^"
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