Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-16224

InvalidQueryException: Order by on unknown column From cassandra-diff

    XMLWordPrintableJSON

Details

    Description

      Diff job fails with the following error,

        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)
      

      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.

      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);
      

      Attachments

        Issue Links

          Activity

            People

              Jyothsnakonisa Jyothsna Konisa
              yifanc Yifan Cai
              Jyothsna Konisa
              Marcus Eriksson, Yifan Cai
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: