Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-534

Missing implementation of ResultSetMetaData.getColumnClassName(int)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0-incubating
    • 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"));
      

      Attachments

        1. resultsetmetadata.patch
          2 kB
          Knut Forkalsrud

        Activity

          People

            julianhyde Julian Hyde
            knut-apache@forkalsrud.org Knut Forkalsrud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: