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

Aliases need to be in metadata #5

Open
jdiamond opened this issue Oct 23, 2024 · 0 comments
Open

Aliases need to be in metadata #5

jdiamond opened this issue Oct 23, 2024 · 0 comments

Comments

@jdiamond
Copy link

Create a table like this with spanner-cli:

create table aliases (
  id string(max),
  foo string(max),
  last_commit_ts timestamp options (allow_commit_timestamp=true)
) primary key (id);

Insert the metadata:

INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence) VALUES ('test', 'aliases', 'id', 'text', true, 0);
INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence) VALUES ('test', 'aliases', 'foo', 'text', false, 0);

Insert a test record:

insert into aliases (id, foo) values ('a', 'b');

Query with an alias works in spanner-cli:

select id, foo as bar from aliases;

Try to query with an alias from cqlsh:

select id, foo as bar from test.aliases;

cqlsh shows this error:

InvalidRequest: Error from server: code=2200 [Invalid query] message="could not find column(bar) metadata. Please insert all the table and column information into the config table"

Proxy shows this error:

{"level":"error","time":"2024-10-23T00:13:34.603Z","caller":"proxy/proxy.go:1507","msg":"Error occurred at spanner - ","Query":"select id, foo as bar from test.aliases;","error":"could not find column(bar) metadata. Please insert all the table and column information into the config table","stacktrace":"github.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxy.(*client).handleQuery\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxy/proxy.go:1507\ngithub.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxy.(*client).Receive\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxy/proxy.go:641\ngithub.com/ollionorg/cassandra-to-spanner-proxy/third_party/datastax/proxycore.(*Conn).read\n\t/go/src/cassandra-to-spanner-proxy/third_party/datastax/proxycore/conn.go:114"}

Insert the alias into the metadata:

INSERT INTO TableConfigurations (KeySpaceName, TableName, ColumnName, ColumnType, IsPrimaryKey, PK_Precedence) VALUES ('test', 'aliases', 'bar', 'text', false, 0);

Restart the proxy.

Now querying with an alias from cqlsh works.

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