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

Map type issues #40

Open
Deep1998 opened this issue Feb 6, 2025 · 1 comment
Open

Map type issues #40

Deep1998 opened this issue Feb 6, 2025 · 1 comment

Comments

@Deep1998
Copy link

Deep1998 commented Feb 6, 2025

I was testing out the map type with the following configuration:

CREATE TABLE map_text_boolean_table (
 id INT64 NOT NULL,
 val JSON
) PRIMARY KEY(id);


CREATE TABLE map_text_text_table (
 id INT64 NOT NULL,
 val JSON
) PRIMARY KEY(id);


CREATE TABLE map_text_timestamp_table (
 id INT64 NOT NULL,
 val JSON
) PRIMARY KEY(id);


-- map_text_boolean_table
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_boolean_table', 'id', 'int', TRUE, 1);
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_boolean_table', 'val', 'map<text, boolean>', FALSE, 0);


-- map_text_text_table
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_text_table', 'id', 'int', TRUE, 1);
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_text_table', 'val', 'map<text, text>', FALSE, 0);


-- map_text_timestamp_table
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_timestamp_table', 'id', 'int', TRUE, 1);
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence)
VALUES ('testkeyspace', 'map_text_timestamp_table', 'val', 'map<text, timestamp>', FALSE, 0);


I ran into the following issues:

map<text, boolean> : corrupted value

cqlsh:testkeyspace> INSERT INTO map_text_boolean_table (id, val) VALUES (1, {'key1': TRUE, 'key2': FALSE});
cqlsh:testkeyspace>  SELECT * FROM map_text_boolean_table;

 id | val
----+-----------------
  1 | {'key1': False}

(1 rows)

map<text, text> : read failure, spanner val seems corrupted {"key1":"value1,key2:value2"}

cqlsh:testkeyspace> INSERT INTO map_text_text_table (id, val) VALUES (1, {'key1': 'value1', 'key2': 'value2'});
cqlsh:testkeyspace> select * from map_text_text_table;
InvalidRequest: Error from server: code=2200 [Invalid query] message="error while encoding data - error deserializing JSON to map[string]string: invalid character '<' looking for beginning of value, 1, {fields: [name:"id"  type:{code:INT64} name:"val"  type:{code:JSON}], values: [string_value:"2" null_value:NULL_VALUE]} "

map<text, timestamp> : read failure, spanner val seems correct {"key1":"2025-02-06T10:00:00Z"}

INSERT INTO map_text_timestamp_table (id, val) VALUES (1, {'key1': '2025-02-06T10:00:00Z'});
cqlsh:testkeyspace> SELECT * FROM map_text_timestamp_table;
InvalidRequest: Error from server: code=2200 [Invalid query] message="error while encoding data - error deserializing JSON to map[string]time.Time: invalid character '<' looking for beginning of value, 1, {fields: [name:"id"  type:{code:INT64} name:"val"  type:{code:JSON}], values: [string_value:"2" null_value:NULL_VALUE]} "
@Deep1998
Copy link
Author

Deep1998 commented Feb 7, 2025

Update: These types work correctly for prepared statements.
These only seem to be occuring on CQLSH

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

1 participant