You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2021/09/24 00:44:10 UTC
[calcite] 02/02: [CALCITE-4793]
CassandraAdapterDataTypesTest.testCollectionsInnerValues fails depending on
the user timezone (Alessandro Solimando)
This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
commit d4640d0bcca6ba77c4b0911f48b39f4bf47d757f
Author: Alessandro Solimando <al...@gmail.com>
AuthorDate: Thu Sep 23 16:27:27 2021 +0200
[CALCITE-4793] CassandraAdapterDataTypesTest.testCollectionsInnerValues fails depending on the user timezone (Alessandro Solimando)
---
.../calcite/test/CassandraAdapterDataTypesTest.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/cassandra/src/test/java/org/apache/calcite/test/CassandraAdapterDataTypesTest.java b/cassandra/src/test/java/org/apache/calcite/test/CassandraAdapterDataTypesTest.java
index ffed5e0..c76508d 100644
--- a/cassandra/src/test/java/org/apache/calcite/test/CassandraAdapterDataTypesTest.java
+++ b/cassandra/src/test/java/org/apache/calcite/test/CassandraAdapterDataTypesTest.java
@@ -16,7 +16,10 @@
*/
package org.apache.calcite.test;
+import org.apache.calcite.avatica.util.DateTimeUtils;
+
import com.datastax.driver.core.Session;
+import com.datastax.driver.core.TypeCodec;
import com.google.common.collect.ImmutableMap;
import org.cassandraunit.CQLDataLoader;
@@ -27,6 +30,10 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
+import java.util.Calendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
/**
* Tests for the {@code org.apache.calcite.adapter.cassandra} package related to data types.
*
@@ -187,6 +194,12 @@ class CassandraAdapterDataTypesTest {
}
@Test void testCollectionsInnerValues() {
+ // timestamp retrieval depends on the user timezone, we must compute the expected result
+ long v = TypeCodec.timestamp().parse("2015-05-03 13:30:54.234").getTime();
+ // UTC timestamp is adjusted using the offset from the user timezone
+ v -= Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT).getTimeZone().getOffset(v);
+ String expectedTimestamp = DateTimeUtils.unixTimestampToString(v);
+
CalciteAssert.that()
.with(DTCASSANDRA)
.query("select \"f_list\"[1], "
@@ -199,7 +212,7 @@ class CassandraAdapterDataTypesTest {
+ "; EXPR$1=v1"
+ "; 1=3000000000"
+ "; 2=30ff87"
- + "; 3=2015-05-03 11:30:54\n");
+ + "; 3=" + expectedTimestamp + "\n");
}
// frozen collections should not affect the row type