Skip to content

Commit

Permalink
Pickup avatica.version from project properties and run tests accordingly
Browse files Browse the repository at this point in the history
By doing this we are not disabling any test completely while waiting for the Avatica upgrade.
Moreover, once the upgrade happens some tests will fail forcing us to do the necessary cleanup.
  • Loading branch information
zabetak committed Oct 17, 2023
1 parent 14d3061 commit f7caa3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ allprojects {
passProperty("user.language", "TR")
passProperty("user.country", "tr")
passProperty("user.timezone", "UTC")
passProperty("calcite.avatica.version", props.string("calcite.avatica.version"))
val props = System.getProperties()
for (e in props.propertyNames() as `java.util`.Enumeration<String>) {
if (e.startsWith("calcite.") || e.startsWith("avatica.")) {
Expand Down
21 changes: 13 additions & 8 deletions testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,6 @@ public class SqlOperatorTest {

public static final boolean TODO = false;

/** Whether Apache Calcite Avatica 1.24.0 is released.
* This release will be expected to contain the
* <a href="https://issues.apache.org/jira/browse/CALCITE-5678">[CALCITE-5678],
* which Calcite will reject date literals not satisfying Gregorian calendar,
* per SQL standard</a>. */
public static final boolean AVATICA_1_24_0_RELEASED = false;

/**
* Regular expression for a SQL TIME(0) value.
*/
Expand Down Expand Up @@ -1261,7 +1254,8 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
f.checkScalar("cast('1945-02-24 12:42:25.34' as TIMESTAMP(2))",
"1945-02-24 12:42:25.34", "TIMESTAMP(2) NOT NULL");
}
if (AVATICA_1_24_0_RELEASED) {
// Remove the if condition and the else block once CALCITE-6053 is fixed
if (TestUtil.AVATICA_VERSION.startsWith("1.0.0-dev-main")) {
if (castType == CastType.CAST) {
f.checkFails("cast('1945-2-2 12:2:5' as TIMESTAMP)",
"Invalid DATE value, '1945-2-2 12:2:5'", true);
Expand All @@ -1281,6 +1275,17 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
f.checkNull("cast('1945-01-24 25:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-1-24 12:23:34.454' as TIMESTAMP)");
}
} else {
f.checkScalar("cast('1945-2-2 12:2:5' as TIMESTAMP)",
"1945-02-02 12:02:05", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1241241' as TIMESTAMP)",
"1241-01-01 00:00:00", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1945-20-24 12:42:25.34' as TIMESTAMP)",
"1946-08-26 12:42:25", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1945-01-24 25:42:25.34' as TIMESTAMP)",
"1945-01-25 01:42:25", "TIMESTAMP(0) NOT NULL");
f.checkScalar("cast('1945-1-24 12:23:34.454' as TIMESTAMP)",
"1945-01-24 12:23:34", "TIMESTAMP(0) NOT NULL");
}
f.checkFails("cast('nottime' as TIMESTAMP)", BAD_DATETIME_MESSAGE, true);

Expand Down
2 changes: 2 additions & 0 deletions testkit/src/main/java/org/apache/calcite/util/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public abstract class TestUtil {
private static final String JAVA_VERSION =
System.getProperties().getProperty("java.version");

public static final String AVATICA_VERSION =
System.getProperty("calcite.avatica.version");
private static final Supplier<Integer> GUAVA_MAJOR_VERSION =
Suppliers.memoize(TestUtil::computeGuavaMajorVersion)::get;

Expand Down

0 comments on commit f7caa3f

Please sign in to comment.