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

NUMERIC type conflict in ZetaSQL when using DEFAULT clause #101

Closed
dtest opened this issue Feb 21, 2023 · 3 comments
Closed

NUMERIC type conflict in ZetaSQL when using DEFAULT clause #101

dtest opened this issue Feb 21, 2023 · 3 comments

Comments

@dtest
Copy link

dtest commented Feb 21, 2023

When trying to insert a row to a table that defines a NUMERIC datatype that uses DEFAULT value, I receive a ZetaSQL data type check fatal error and the emulator stops.

Emulator version: 1.5.0

Example schema:

CREATE TABLE players (
  playerUUID STRING(36) NOT NULL,
  player_name STRING(64) NOT NULL,
  email STRING(MAX) NOT NULL,  
  account_balance NUMERIC NOT NULL DEFAULT (0.00),
) PRIMARY KEY(playerUUID);

Steps to repeat.

Start the emulator:

docker run -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator:1.5.0 &
gcloud spanner instances create test-instance --config=regional-us-central1 \
  --description="Test Instance" --nodes=1
gcloud spanner databases create test-database --instance=test-instance

Connect to spanner-cli:

$ spanner-cli -i test-instance -d test-database -p test-project
Connected.

spanner> CREATE TABLE players (
      ->   playerUUID STRING(36) NOT NULL,
      ->   player_name STRING(64) NOT NULL,
      ->   email STRING(MAX) NOT NULL,  
      ->   account_balance NUMERIC NOT NULL DEFAULT (0.00),
      -> ) PRIMARY KEY(playerUUID);
Query OK, 0 rows affected (0.01 sec)\

spanner> INSERT INTO players (playerUUID, player_name, email) VALUES ('adsfaioja-dsfpoijasf-asdfpiojasdf', 'test player', 'player1@gmail.com');
ERROR: spanner: code = "DeadlineExceeded", desc = "context deadline exceeded"

Output from the emulator:

2023/02/21 14:49:16 gateway.go:142: gRPC server listening at 0.0.0.0:9010
export SPANNER_DATABASE_ID=test-database2023-02-21 14:53:37  FATAL  value.h : 576 : Check failed: ::absl::OkStatus() == ::zetasql::status_internal::AsStatus((value)) (OK vs. INTERNAL: ZETASQL_RET_CHECK failure (external/com_google_zetasql/zetasql/public/value.cc:252) field_type->Equals(value_type) 
Field type: NUMERIC
vs
Value type: DOUBLE) 
2023/02/21 14:53:39 gateway.go:107: Shutting down gateway server since grpc server is terminated.
@dtest
Copy link
Author

dtest commented Feb 21, 2023

I should point out that adding rows via mutations (in for example my golang app), everything works fine.

So this is only when inserting with DML (with ZetaSQL).

@gauravpurohit06
Copy link
Collaborator

Thanks for filing the request. We are tracking the enhancement with the internal development team and will get back on it.

@gauravpurohit06
Copy link
Collaborator

Thank you @dtest for filing the issue. The issue has been fixed in the v@1.5.5 of emulator.

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

2 participants