The output of the COLUMN_DEFAULT column in Cloud Spanner Emulator's INFORMATION_SCHEMA.COLUMNS may be missing when a function is used in the DEFAULT Value. Specifically, the brackets at the end of the function are missing.
For example, create the following table on the Cloud Spanner Emulator v1.5.4.
CREATE TABLE test_table (
id INT64 NOT NULL,
col_default_timestamp TIMESTAMP DEFAULT (CURRENT_TIMESTAMP())
) PRIMARY KEY(id);
Then query INFORMATION_SCHEMA.COLUMNS.
SELECT
COLUMN_NAME,
COLUMN_DEFAULT
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME="test_table";
As mentioned above, the output should be CURRENT_TIMESTAMP(), but it is output as CURRENT_TIMESTAMP(. The closing bracket ) is missing. As far as I have tested, this only occurs in Cloud Spanner Emulator v1.5.1 and later. v1.4.8 and v.1.5.0 print the expected output.
This may seem like a minor issue, but if the results of INFORMATION_SCHEMA.COLUMNS are used in the test of the application, the test will fail because the expected output is not obtained.
The output of the COLUMN_DEFAULT column in Cloud Spanner Emulator's INFORMATION_SCHEMA.COLUMNS may be missing when a function is used in the DEFAULT Value. Specifically, the brackets at the end of the function are missing.
For example, create the following table on the Cloud Spanner Emulator v1.5.4.
Then query INFORMATION_SCHEMA.COLUMNS.
Expected output:
Actual output:
As mentioned above, the output should be
CURRENT_TIMESTAMP()
, but it is output asCURRENT_TIMESTAMP(
. The closing bracket)
is missing. As far as I have tested, this only occurs in Cloud Spanner Emulator v1.5.1 and later. v1.4.8 and v.1.5.0 print the expected output.https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/compare/v1.5.0...v1.5.1 The brackets in the value returned by
col->expression().value()
appear to have changed between v1.5.0 and v1.5.1, according to the revision history ofbackend/schema/updater/schema_updater_tests/column_default_values.cc.
https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/blob/v1.5.4/backend/query/information_schema_catalog.cc#L388-L389 I have not checked all the processes, but the process of trimming the brackets
()
is still left, so I suspect that only the)
ofCURRENT_TIMESTAMP()
was deleted here.This may seem like a minor issue, but if the results of
INFORMATION_SCHEMA.COLUMNS
are used in the test of the application, the test will fail because the expected output is not obtained.