cloudspannerecosystem / spanner-cli

Interactive command line tool for Cloud Spanner
Apache License 2.0
230 stars 28 forks source link

Support Partitioned DML with statement hints #193

Open apstndb opened 1 month ago

apstndb commented 1 month ago

DMLs can be prefixed by statement hints.

https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax#delete-statement

[statement_hint_expr] UPDATE table_name [table_hint_expr] [[AS] alias]

https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax#update-statement

[statement_hint_expr] UPDATE table_name [table_hint_expr] [[AS] alias]

It seems that only permitted statement hint is PDML_MAX_PARALLELISM for Partitioned DML, so only we need is relaxing pattern of pdmlRe.

https://github.com/cloudspannerecosystem/spanner-cli/blob/e44e60f428b4206024673bc4a36955e8981bc17a/statement.go#L105

yfuruyama commented 1 month ago

Thank you for catching this.

PARTITIONED statement is a spanner-cli specific statement, so it's a little bit tricky to decide where the statement hint should be placed.

  1. @{hint} PARTITIONED UPDATE ...
  2. PARTITIONED @{hint} UPDATE ...

It's possible that other prefixes will be supported in front of DML syntax, so I think option 2 might be better. Then we can think of the PARTITIONED statement syntax as PARTITIONED [DML statement].