Yifan Cai created CASSANDRA-16224:
-------------------------------------

             Summary: InvalidQueryException: Order by on unknown column From 
cassandra-diff
                 Key: CASSANDRA-16224
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-16224
             Project: Cassandra
          Issue Type: Bug
          Components: Tool/diff
            Reporter: Yifan Cai


Diff job fails with the following error,
{code:java}
  Caused by: shaded.com.datastax.driver.core.exceptions.InvalidQueryException: 
Order by on unknown column <column_name>
  at 
shaded.com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:49)
  at 
shaded.com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:35)
  at 
shaded.com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:97)
  at mme.cassandraclient.SessionWrapper.prepare(SessionWrapper.java:215)
  at 
org.apache.cassandra.diff.DiffCluster.getFullStatement(DiffCluster.java:272)
  at 
org.apache.cassandra.diff.DiffCluster.getStatementForTable(DiffCluster.java:204)
  at org.apache.cassandra.diff.DiffCluster.keyReader(DiffCluster.java:188)
  at 
org.apache.cassandra.diff.DiffCluster.fetchPartitionKeys(DiffCluster.java:125)
  at 
org.apache.cassandra.diff.DiffCluster.lambda$getPartitionKeys$0(DiffCluster.java:114)
  at org.apache.cassandra.diff.RetryStrategy.retry(RetryStrategy.java:21)
  at 
org.apache.cassandra.diff.DiffCluster.getPartitionKeys(DiffCluster.java:113)
{code}

The cause is that when building the select query, the ordered-by column names 
are not quoted. The server only sees the field names in lowercase, and it is 
unable to recognize. 

A simple unit test to prove that the field name needs to be quoted in the query 
builder in order to have the built query preserve the quotes. 

{code:java}
query = "SELECT * FROM t WHERE a='foo' ORDER BY \"bCol\" DESC;";
select = select().from("t").where(eq("a", "foo")).orderBy(desc("\"bCol\""));
assertEquals(select.toString(), query);
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to