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 nested updates #252

Open
apstndb opened this issue Jan 1, 2025 · 0 comments · May be fixed by #263
Open

Support nested updates #252

apstndb opened this issue Jan 1, 2025 · 0 comments · May be fixed by #263

Comments

@apstndb
Copy link
Contributor

apstndb commented Jan 1, 2025

https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax?hl=en#nested-updates-protocol-buffers

UPDATE Singers s
SET
    (DELETE FROM s.SingerInfo.Residence r WHERE r.City = 'Seattle'),
    (UPDATE s.SingerInfo.Residence r SET r.end_year = 2015 WHERE r.City = 'Eugene'),
    (INSERT s.Albums.Song VALUES ("songtitle: 'The Second Best Song'"))
WHERE SingerId = 3 AND s.Albums.title = 'Go! Go! Go!';

Note

The formal syntax is not yet well described in the Spanner DML syntax reference, but we can reference ZetaSQL DML syntax reference.

https://github.com/google/zetasql/blob/2024.11.1/docs/data-manipulation-language.md#update-statement

UPDATE target_name
SET set_clause
[FROM from_clause]
WHERE condition [ASSERT_ROWS_MODIFIED n] [ then_return_clause ]

set_clause:
  update_item[, ...]

update_item:
  {
    path_expression = expression
    | path_expression = DEFAULT
    | (dml_stmt)
  }

...

dml_stmt:
  { insert_statement | update_statement | delete_statement }
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

Successfully merging a pull request may close this issue.

1 participant