Last active
February 4, 2016 23:50
-
-
Save dmarti/109093edb813d52ff011 to your computer and use it in GitHub Desktop.
This file contains 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
public class TimeuuidTest extends CQLTester | |
{ | |
/** | |
* Migrated from cql_tests.py:TestCQL.timeuuid_test() | |
*/ | |
@Test | |
public void testTimeuuid() throws Throwable | |
{ | |
createTable("CREATE TABLE %s (k int, t timeuuid, PRIMARY KEY(k, t))"); | |
assertInvalidSyntaxMessage(null, "INSERT INTO %s (k, t) VALUES (0, 2012-11-07 18:18:22-0800)"); | |
for (int i = 0; i < 4; i++) | |
execute("INSERT INTO %s (k, t) VALUES (0, now())"); | |
Object[][] rows = getRows(execute("SELECT * FROM %s")); | |
assertEquals(4, rows.length); | |
assertRowCount(execute("SELECT * FROM %s WHERE k = 0 AND t >= ?", rows[0][1]), 4); | |
assertEmpty(execute("SELECT * FROM %s WHERE k = 0 AND t < ?", rows[0][1])); | |
assertRowCount(execute("SELECT * FROM %s WHERE k = 0 AND t > ? AND t <= ?", rows[0][1], rows[2][1]), 2); | |
assertRowCount(execute("SELECT * FROM %s WHERE k = 0 AND t = ?", rows[0][1]), 1); | |
assertInvalid("SELECT dateOf(k) FROM %s WHERE k = 0 AND t = ?", rows[0][1]); | |
for (int i = 0; i < 4; i++) | |
{ | |
long timestamp = UUIDs.unixTimestamp((UUID) rows[i][1]); | |
assertRows(execute("SELECT dateOf(t), unixTimestampOf(t) FROM %s WHERE k = 0 AND t = ?", rows[i][1]), | |
row(new Date(timestamp), timestamp)); | |
} | |
assertEmpty(execute("SELECT t FROM %s WHERE k = 0 AND t > maxTimeuuid(1234567) AND t < minTimeuuid('2012-11-07 18:18:22-0800')")); | |
} | |
/** | |
* Test for 5386, | |
* migrated from cql_tests.py:TestCQL.function_and_reverse_type_test() | |
*/ | |
@Test | |
public void testDescClusteringOnTimeuuid() throws Throwable | |
{ | |
createTable("CREATE TABLE %s (k int, c timeuuid, v int, PRIMARY KEY (k, c)) WITH CLUSTERING ORDER BY (c DESC)"); | |
execute("INSERT INTO %s (k, c, v) VALUES (0, now(), 0)"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment