1
votes

A Google Spanner DDL script runs successfully when submitted in the Spanner Console, but when executed via the "glcoud spanner databases ddl update" command using the "--ddl-file" argument it consistently fails with the error:

(gcloud.spanner.databases.ddl.update) INVALID_ARGUMENT: Error parsing Spanner DDL statement: \n : Syntax error on line 1, column 1: Encountered 'EOF' while parsing: ddl_statement

  • '@type': type.googleapis.com/google.rpc.LocalizedMessage locale: en-US message: |- Error parsing Spanner DDL statement: : Syntax error on line 1, column 1: Encountered 'EOF' while parsing: ddl_statement

Example of the command:

gcloud spanner databases ddl update test-db
--instance=test-instance
--ddl-file=table.ddl

cat table.ddl

CREATE TABLE regions ( region_id STRING(2) NOT NULL, name STRING(13) NOT NULL, ) PRIMARY KEY (region_id);

There is only one other reference to this identical situation on the internet. Has anyone got the "ddl-file" argument to successfully work?

1

1 Answers

1
votes

The problem is (most probably) caused by the last semi colon in your DDL script. It seems that the --ddl-file option accepts scripts with multiple DDL statements that may be separated by semi colons (;), but the last statement should not be terminated by a semi colon. Doing so will cause gcloud to try to parse another DDL statement after the last, only to determine that there is none, and thereby throwing an Unexpected end of file error.

So TLDR: Remove the last semi colon in your script and it should work.