Created
July 13, 2018 21:37
-
-
Save DikangGu/e538ed2de22b74e49b8dd43f7093a996 to your computer and use it in GitHub Desktop.
Cql query returns different results in 2.2 and 3.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.cassandra.cql3; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import org.apache.cassandra.config.DatabaseDescriptor; | |
import org.apache.cassandra.dht.ByteOrderedPartitioner; | |
import org.apache.cassandra.transport.Server; | |
public class ComparisonTest extends CQLTester | |
{ | |
int cqlVersion = Server.VERSION_3; | |
@BeforeClass | |
public static void setUp() | |
{ | |
// This line is needed in 2.2, not in 3.0 | |
// DatabaseDescriptor.setPartitioner(ByteOrderedPartitioner.instance); | |
} | |
@Test | |
public void testCQL() throws Throwable | |
{ | |
createTable("CREATE TABLE %s (k int, c1 int, c2 int, v int, PRIMARY KEY(k, c1, c2)) WITH CLUSTERING ORDER BY (c1 DESC, c2 ASC)"); | |
execute("INSERT INTO %s(k, c1, c2, v) VALUES (?, ?, ?, ?)", 1, 10, 0, 1); | |
execute("INSERT INTO %s(k, c1, c2, v) VALUES (?, ?, ?, ?)", 1, 10, 10, 2); | |
execute("INSERT INTO %s(k, c1, c2, v) VALUES (?, ?, ?, ?)", 1, 1, 0, 3); | |
execute("INSERT INTO %s(k, c1, c2, v) VALUES (?, ?, ?, ?)", 1, 1, 10, 4); | |
com.datastax.driver.core.ResultSet res = executeNet(cqlVersion, "SELECT * from %s WHERE k = 1 AND (c1, c2) >= (? , ?) AND (c1, c2) <= (?, ?)", 1, 10, 10, 0); | |
System.out.println(res.all()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment