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/11/14 03:02:37 UTC
[calcite] branch master updated: [CALCITE-4877] Enable schema.iq test, with variants depending on Avatica version
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
The following commit(s) were added to refs/heads/master by this push:
new 07e420b [CALCITE-4877] Enable schema.iq test, with variants depending on Avatica version
07e420b is described below
commit 07e420bfc36e8f217f5c3459fdf6c1ede609cb80
Author: Julian Hyde <jh...@apache.org>
AuthorDate: Sat Nov 13 13:34:37 2021 -0800
[CALCITE-4877] Enable schema.iq test, with variants depending on Avatica version
Close apache/calcite#2608
---
.../src/main/java/org/apache/calcite/util/Bug.java | 30 ++++++++++++++++++++++
server/src/test/resources/sql/schema.iq | 13 +++++++---
.../java/org/apache/calcite/test/QuidemTest.java | 12 +++++++++
3 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/util/Bug.java b/core/src/main/java/org/apache/calcite/util/Bug.java
index 85531a2..61df590 100644
--- a/core/src/main/java/org/apache/calcite/util/Bug.java
+++ b/core/src/main/java/org/apache/calcite/util/Bug.java
@@ -16,6 +16,10 @@
*/
package org.apache.calcite.util;
+import org.apache.calcite.avatica.AvaticaUtils;
+
+import java.util.Objects;
+
/**
* Holder for a list of constants describing which bugs which have not been
* fixed.
@@ -201,6 +205,14 @@ public abstract class Bug {
* fixed. */
public static final boolean CALCITE_4213_FIXED = false;
+ /** Whether
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-4877">[CALCITE-4877]
+ * Make the exception information of class not found more explicit</a> is
+ * fixed. The actual fix is in Avatica, and we don't know the precise version
+ * of Avatica, so we have to deduce whether it is fixed from Avatica's
+ * behavior. We memoize the result so that we don't generate lots of exceptions. */
+ public static final boolean CALCITE_4877_FIXED = isCalcite4877Fixed();
+
/**
* Use this to flag temporary code.
*/
@@ -237,4 +249,22 @@ public abstract class Bug {
Util.discard(remark);
return false;
}
+
+ private static boolean isCalcite4877Fixed() {
+ try {
+ AvaticaUtils.instantiatePlugin(Integer.class,
+ "org.apache.calcite.NonExistent");
+ } catch (RuntimeException e) {
+ // Avatica 1.19 and earlier gives
+ // Property 'org.apache.calcite.NonExistent' not valid for plugin type
+ // java.lang.Integer
+ // Avatica 1.20 and later gives
+ // Property 'org.apache.calcite.NonExistent' not valid as
+ // 'org.apache.calcite.NonExistent' not found in the classpath
+ return Objects.equals(e.getMessage(),
+ "Property 'org.apache.calcite.NonExistent' not valid as "
+ + "'org.apache.calcite.NonExistent' not found in the classpath");
+ }
+ return false;
+ }
}
diff --git a/server/src/test/resources/sql/schema.iq b/server/src/test/resources/sql/schema.iq
index 1976d26..9a91c97 100755
--- a/server/src/test/resources/sql/schema.iq
+++ b/server/src/test/resources/sql/schema.iq
@@ -65,9 +65,16 @@ create schema if not exists s;
!update
# Bad library
-# create foreign schema fs library 'com.example.BadSchemaFactory';
-# Property 'com.example.BadSchemaFactory' not valid for plugin type org.apache.calcite.schema.SchemaFactory
-# !error
+!if (fixed.calcite4877) {
+create foreign schema fs library 'com.example.BadSchemaFactory';
+Property 'com.example.BadSchemaFactory' not valid as 'com.example.BadSchemaFactory' not found in the classpath
+!error
+!}
+!if (not.fixed.calcite4877) {
+create foreign schema fs library 'com.example.BadSchemaFactory';
+Property 'com.example.BadSchemaFactory' not valid for plugin type org.apache.calcite.schema.SchemaFactory
+!error
+!}
# Bad type
create foreign schema fs type 'bad';
diff --git a/testkit/src/main/java/org/apache/calcite/test/QuidemTest.java b/testkit/src/main/java/org/apache/calcite/test/QuidemTest.java
index 21699dc..fe09872 100644
--- a/testkit/src/main/java/org/apache/calcite/test/QuidemTest.java
+++ b/testkit/src/main/java/org/apache/calcite/test/QuidemTest.java
@@ -79,6 +79,18 @@ public abstract class QuidemTest {
return Bug.CALCITE_1045_FIXED;
case "calcite1048":
return Bug.CALCITE_1048_FIXED;
+ case "calcite4877":
+ return Bug.CALCITE_4877_FIXED;
+ }
+ return null;
+ };
+ case "not":
+ return (Function<String, Object>) v -> {
+ final Object o = getEnv(v);
+ if (o instanceof Function) {
+ @SuppressWarnings("unchecked") final Function<String, Object> f =
+ (Function<String, Object>) o;
+ return (Function<String, Object>) v2 -> !((Boolean) f.apply(v2));
}
return null;
};