Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6356] Upgrade Calcite to Avatica 1.25.0 #3755

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions core/src/main/java/org/apache/calcite/util/Bug.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,11 @@ public abstract class Bug {
* Fix to be available with Avatica 1.24.0 [CALCITE-6053] */
public static final boolean CALCITE_6092_FIXED = false;

/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE-6053">[CALCITE-6053]
* Upgrade Calcite to Avatica 1.24.0</a> is fixed.
*/
public static final boolean CALCITE_6053_FIXED = false;

/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE-6248">[CALCITE-6248]
* Illegal dates are accepted by casts</a> is fixed.
* Fix to be available with Avatica 1.25.0 */
public static final boolean CALCITE_6248_FIXED = false;

/**
* Use this to flag temporary code.
*/
public static final boolean TODO_FIXED = false;

/** Whether
* <a href="https://issues.apache.org/jira/browse/CALCITE-6282">[CALCITE-6282]
* Avatica ignores time precision when returning TIME results</a> is fixed.
* This should be removed once the bug is fixed in Avatica, and
* Calcite switches to the most recent version of Avatica.
* This is expected to be fixed in Avatica 1.25.0. */
public static final boolean CALCITE_6282_FIXED = false;

/**
* Use this method to flag temporary code.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ systemProp.org.gradle.internal.publish.checksums.insecure=true
# Release version can be generated by using -Prelease or -Prc=<int> arguments
calcite.version=1.37.0
# This is a version to be used from Maven repository. It can be overridden by localAvatica below
calcite.avatica.version=1.23.0
calcite.avatica.version=1.25.0

# The options below configures the use of local clone (e.g. testing development versions)
# You can pass un-comment it, or pass option -PlocalReleasePlugins, or -PlocalReleasePlugins=<path>
Expand Down
144 changes: 64 additions & 80 deletions testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1167,11 +1167,9 @@ void testCastDateTime(CastType castType, SqlOperatorFixture f) {
"12:42:26", "TIME(0) NOT NULL");
}

if (Bug.CALCITE_6282_FIXED) {
// test precision
f.checkScalar("cast(TIME '12:42:25.34' as TIME(2))",
"12:42:25.34", "TIME(2) NOT NULL");
}
// test precision
f.checkScalar("cast(TIME '12:42:25.34' as TIME(2))",
"12:42:25.34", "TIME(2) NOT NULL");

f.checkScalar("cast(DATE '1945-02-24' as DATE)",
"1945-02-24", "DATE NOT NULL");
Expand Down Expand Up @@ -1230,10 +1228,8 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
f.checkScalar("cast('12:42:25.34' as TIME)",
"12:42:25", "TIME(0) NOT NULL");

if (Bug.CALCITE_6282_FIXED) {
f.checkScalar("cast('12:42:25.34' as TIME(2))",
"12:42:25.34", "TIME(2) NOT NULL");
}
f.checkScalar("cast('12:42:25.34' as TIME(2))",
"12:42:25.34", "TIME(2) NOT NULL");

if (castType == CastType.CAST) {
f.checkFails("cast('nottime' as TIME)", BAD_DATETIME_MESSAGE, true);
Expand Down Expand Up @@ -1270,28 +1266,26 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
f.checkScalar("cast('2004-02-29' as TIMESTAMP)",
"2004-02-29 00:00:00", "TIMESTAMP(0) NOT NULL");

if (Bug.CALCITE_6282_FIXED) {
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 (castType == CastType.CAST) {
f.checkFails("cast('1945-2-2 12:2:5' as TIMESTAMP)",
"Invalid DATE value, '1945-2-2 12:2:5'", true);
f.checkFails("cast('1241241' as TIMESTAMP)",
"Invalid DATE value, '1241241'", true);
f.checkFails("cast('1945-20-24 12:42:25.34' as TIMESTAMP)",
"Invalid DATE value, '1945-20-24 12:42:25.34'", true);
f.checkFails("cast('1945-01-24 25:42:25.34' as TIMESTAMP)",
"Value of HOUR field is out of range in '1945-01-24 25:42:25.34'", true);
f.checkFails("cast('1945-1-24 12:23:34.454' as TIMESTAMP)",
"Invalid DATE value, '1945-1-24 12:23:34.454'", true);
} else {
// test cases for 'SAFE_CAST' and 'TRY_CAST'
f.checkNull("cast('1945-2-2 12:2:5' as TIMESTAMP)");
f.checkNull("cast('1241241' as TIMESTAMP)");
f.checkNull("cast('1945-20-24 12:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-01-24 25:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-1-24 12:23:34.454' as TIMESTAMP)");
}
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 (castType == CastType.CAST) {
f.checkFails("cast('1945-2-2 12:2:5' as TIMESTAMP)",
"Invalid DATE value, '1945-2-2 12:2:5'", true);
f.checkFails("cast('1241241' as TIMESTAMP)",
"Invalid DATE value, '1241241'", true);
f.checkFails("cast('1945-20-24 12:42:25.34' as TIMESTAMP)",
"Invalid DATE value, '1945-20-24 12:42:25.34'", true);
f.checkFails("cast('1945-01-24 25:42:25.34' as TIMESTAMP)",
"Value of HOUR field is out of range in '1945-01-24 25:42:25.34'", true);
f.checkFails("cast('1945-1-24 12:23:34.454' as TIMESTAMP)",
"Invalid DATE value, '1945-1-24 12:23:34.454'", true);
} else {
// test cases for 'SAFE_CAST' and 'TRY_CAST'
f.checkNull("cast('1945-2-2 12:2:5' as TIMESTAMP)");
f.checkNull("cast('1241241' as TIMESTAMP)");
f.checkNull("cast('1945-20-24 12:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-01-24 25:42:25.34' as TIMESTAMP)");
f.checkNull("cast('1945-1-24 12:23:34.454' as TIMESTAMP)");
}
if (castType == CastType.CAST) {
f.checkFails("cast('nottime' as TIMESTAMP)", BAD_DATETIME_MESSAGE, true);
Expand All @@ -1313,14 +1307,12 @@ void testCastStringToDateTime(CastType castType, SqlOperatorFixture f) {
f.checkNull("cast('notdate' as DATE)");
}

if (Bug.CALCITE_6248_FIXED) {
if (castType == CastType.CAST) {
f.checkFails("cast('52534253' as DATE)", BAD_DATETIME_MESSAGE, true);
f.checkFails("cast('1945-30-24' as DATE)", BAD_DATETIME_MESSAGE, true);
} else {
f.checkNull("cast('52534253' as DATE)");
f.checkNull("cast('1945-30-24' as DATE)");
}
if (castType == CastType.CAST) {
f.checkFails("cast('52534253' as DATE)", BAD_DATETIME_MESSAGE, true);
f.checkFails("cast('1945-30-24' as DATE)", BAD_DATETIME_MESSAGE, true);
} else {
f.checkNull("cast('52534253' as DATE)");
f.checkNull("cast('1945-30-24' as DATE)");
}

// cast null
Expand Down Expand Up @@ -11545,16 +11537,14 @@ private static void checkArrayConcatAggFuncFails(SqlOperatorFixture t) {
"(?s)Cannot apply 'FLOOR' to arguments .*", false);
f.checkScalar("floor(time '12:34:56' to minute)",
"12:34:00", "TIME(0) NOT NULL");
if (Bug.CALCITE_6282_FIXED) {
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to second)",
"2015-02-19 12:34:56.00", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to millisecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to microsecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to nanosecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
}
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to second)",
"2015-02-19 12:34:56.00", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to millisecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to microsecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56.78' to nanosecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56' to minute)",
"2015-02-19 12:34:00", "TIMESTAMP(0) NOT NULL");
f.checkScalar("floor(timestamp '2015-02-19 12:34:56' to year)",
Expand Down Expand Up @@ -11592,18 +11582,16 @@ private static void checkArrayConcatAggFuncFails(SqlOperatorFixture t) {
"12:35:00", "TIME(0) NOT NULL");
f.checkScalar("ceil(time '12:59:56' to minute)",
"13:00:00", "TIME(0) NOT NULL");
if (Bug.CALCITE_6282_FIXED) {
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to second)",
"2015-02-19 12:34:57.00", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to millisecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to microsecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to nanosecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.00' to second)",
"2015-02-19 12:34:56.00", "TIMESTAMP(2) NOT NULL");
}
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to second)",
"2015-02-19 12:34:57.00", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to millisecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to microsecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.78' to nanosecond)",
"2015-02-19 12:34:56.78", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56.00' to second)",
"2015-02-19 12:34:56.00", "TIMESTAMP(2) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56' to minute)",
"2015-02-19 12:35:00", "TIMESTAMP(0) NOT NULL");
f.checkScalar("ceil(timestamp '2015-02-19 12:34:56' to year)",
Expand Down Expand Up @@ -11736,30 +11724,26 @@ private static void checkArrayConcatAggFuncFails(SqlOperatorFixture t) {
@Test void testTimestampAdd() {
final SqlOperatorFixture f = fixture();
f.setFor(SqlStdOperatorTable.TIMESTAMP_ADD, VmName.EXPAND);
if (Bug.CALCITE_6282_FIXED) {
MICROSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:27.000",
"TIMESTAMP(3) NOT NULL"));
}
MICROSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:27.000",
"TIMESTAMP(3) NOT NULL"));
SECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:27",
"TIMESTAMP(0) NOT NULL"));
if (Bug.CALCITE_6282_FIXED) {
NANOSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 3000000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:28.000",
"TIMESTAMP(3) NOT NULL"));
NANOSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2000000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:27.000",
"TIMESTAMP(3) NOT NULL"));
}
NANOSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 3000000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:28.000",
"TIMESTAMP(3) NOT NULL"));
NANOSECOND_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2000000000, timestamp '2016-02-24 12:42:25')",
"2016-02-24 12:42:27.000",
"TIMESTAMP(3) NOT NULL"));
MINUTE_VARIANTS.forEach(s ->
f.checkScalar("timestampadd(" + s
+ ", 2, timestamp '2016-02-24 12:42:25')",
Expand Down
Loading