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

ClassCastException byte[] to String with protobuf

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.5.0
    • avatica
    • None

    Description

      java.lang.ClassCastException: [B cannot be cast to java.lang.String
      	at org.apache.calcite.avatica.util.AbstractCursor$StringAccessor.getString(AbstractCursor.java:726)
      	at org.apache.calcite.avatica.AvaticaResultSet.getString(AvaticaResultSet.java:233)
      	at sqlline.Rows$Row.<init>(Rows.java:183)
      	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
      	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
      	at sqlline.SqlLine.print(SqlLine.java:1653)
      	at sqlline.Commands.execute(Commands.java:833)
      	at sqlline.Commands.sql(Commands.java:732)
      	at sqlline.SqlLine.dispatch(SqlLine.java:808)
      	at sqlline.SqlLine.begin(SqlLine.java:681)
      	at sqlline.SqlLine.start(SqlLine.java:398)
      	at sqlline.SqlLine.main(SqlLine.java:292)
      

      JSON encoding doesn't have this issue. The StringAccessor (actually a BinaryFromStringAccessor) expects to get back a String as the object but it gets a byte[].

      Attachments

        Issue Links

          Activity

            elserj Josh Elser added a comment -

            Looks like this may be in part to how sqlline works. Calling getString() on a BINARY/VARBINARY field exhibits the above error where getBytes() works as expected.

            elserj Josh Elser added a comment - Looks like this may be in part to how sqlline works. Calling getString() on a BINARY/VARBINARY field exhibits the above error where getBytes() works as expected.
            elserj Josh Elser added a comment -

            Looks like the value never gets base64-decoded for the JSON case too.

            elserj Josh Elser added a comment - Looks like the value never gets base64-decoded for the JSON case too.
            julianhyde Julian Hyde added a comment -

            If the underlying data is represented using byte[], why is a StringAccessor being created?

            Is StringAccessorTest called?

            julianhyde Julian Hyde added a comment - If the underlying data is represented using byte[], why is a StringAccessor being created? Is StringAccessorTest called?
            elserj Josh Elser added a comment -

            If the underlying data is represented using byte[], why is a StringAccessor being created?

            Good question. I'll need to look at this again to remind myself what is actually happening.

            elserj Josh Elser added a comment - If the underlying data is represented using byte[], why is a StringAccessor being created? Good question. I'll need to look at this again to remind myself what is actually happening.
            elserj Josh Elser added a comment -

            Good question. I'll need to look at this again to remind myself what is actually happening.

            The Type is a VARBINARY but the Rep is actually String. This might be just be an artifact of how JSON was serializing bytes as base64'ed String.

            Let me fix this.

            elserj Josh Elser added a comment - Good question. I'll need to look at this again to remind myself what is actually happening. The Type is a VARBINARY but the Rep is actually String. This might be just be an artifact of how JSON was serializing bytes as base64'ed String. Let me fix this.
            elserj Josh Elser added a comment -

            This might be just be an artifact of how JSON was serializing bytes as base64'ed String.

            Yep, this was exactly the issue. Easy enough fix. Still working on updating CALCITE-903 and then will send a new PR with that across.

            elserj Josh Elser added a comment - This might be just be an artifact of how JSON was serializing bytes as base64'ed String. Yep, this was exactly the issue. Easy enough fix. Still working on updating CALCITE-903 and then will send a new PR with that across.
            julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/6f326d03 . Thanks for the patch, elserj !
            jcamacho Jesús Camacho Rodríguez added a comment - - edited

            Resolved in release 1.5.0 (2015-11-10)

            jcamacho Jesús Camacho Rodríguez added a comment - - edited Resolved in release 1.5.0 (2015-11-10)

            People

              elserj Josh Elser
              elserj Josh Elser
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: