Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0.0-incubating
-
None
-
None
Description
We are running into an obstacle using a very simple Calcite in memory table.
It manifests itself in getting the column classname from ResultSetMetaData. It seems easy enough to fix, at least for our purposes. Here is a proposed patch relative to Git master within the last hour:
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java b/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java index 102590e..fca92b4 100644 --- a/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java +++ b/avatica/src/main/java/org/apache/calcite/avatica/ColumnMetaData.java @@ -106,7 +106,8 @@ public ColumnMetaData( this.readOnly = readOnly; this.writable = writable; this.definitelyWritable = definitelyWritable; - this.columnClassName = columnClassName; + this.columnClassName = columnClassName != null + ? columnClassName : type.representation.clazz.getName(); } private static <T> T first(T t0, T t1) { diff --git a/core/src/test/java/org/apache/calcite/test/TableInRootSchemaTest.java b/core/src/test/java/org/apache/calcite/test/TableInRootSchemaTest.java index 58ebe99..3898422 100644 --- a/core/src/test/java/org/apache/calcite/test/TableInRootSchemaTest.java +++ b/core/src/test/java/org/apache/calcite/test/TableInRootSchemaTest.java @@ -77,6 +77,8 @@ assertThat(resultSetMetaData.getColumnName(1), equalTo("A")); assertThat(resultSetMetaData.getTableName(1), equalTo("SAMPLE")); assertThat(resultSetMetaData.getSchemaName(1), nullValue()); + assertThat(resultSetMetaData.getColumnClassName(1), + equalTo("java.lang.String")); // Per JDBC, column name should be null. But DBUnit requires every column // to have a name, so the driver uses the label. assertThat(resultSetMetaData.getColumnName(2), equalTo("EXPR$1"));