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

ColumnMetadata.column does not appear to do anything. #132

Open
MicahZoltu opened this issue Feb 1, 2016 · 4 comments
Open

ColumnMetadata.column does not appear to do anything. #132

MicahZoltu opened this issue Feb 1, 2016 · 4 comments

Comments

@MicahZoltu
Copy link

cassandraServer.primingClient().prime(PrimingRequest.preparedStatementBuilder()
    .withQuery(query)
    .withColumnTypes(ColumnMetadata.column("foo", PrimitiveType.BIG_INT))
    .build());

PreparedStatement preparedStatement = session.prepare("INSERT INTO my_table (foo)");
BoundStatement boundStatement = new BoundStatement(preparedStatement).setLong("foo", 50);
session.execute(boundStatement);

This results in an exception when calling setLong on the bound statement foo is not a column defined in this metadata. Looking at the logs, I see the priming include the priming of column foo as BIG_INT but when I call session.prepare(...) I don't get back the primed columns: PreparedResultV2(0,5,keyspace,table,List())

@MicahZoltu
Copy link
Author

Just as a wild guess, it is probably this: https://github.com/scassandra/scassandra-server/blob/master/server/src/main/scala/org/scassandra/server/cqlmessages/response/PreparedResult.scala#L74-L77? Is the cassandra protocol documented anywhere?

@MicahZoltu
Copy link
Author

Found the spec, and it appears that I was wrong about the lines that are causing the problem:https://github.com/apache/cassandra/blob/cassandra-2.2/doc/native_protocol_v2.spec#L554-L576

@MicahZoltu
Copy link
Author

I ran into further trouble trying to actually use this change in my application. It appears that now the prepared execution doesn't match the prepared statement. When I try to execute the prepared statement, after it parses the first part of the message and looks for matching primes it doesn't find one because the stored primes have a variableType.size of 0. I can change that to also check prime.prime.columnTypes.size but then when it tries to parse the variables it can't because there aren't any in the prime.

I think I can get past this one with more terrible conditional hacks, but this is all telling me that I am probably doing something wrong.

@chbatey
Copy link
Member

chbatey commented Mar 4, 2016

Hi @Zoltu columns and variables are different so comparing against columsn isn't the right way forward here. What you need to do is use withVariableTypes which will mean that the variable size check will match.

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

Successfully merging a pull request may close this issue.

2 participants