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

ClassCastException byte[] to String with protobuf

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.5.0
    • Component/s: avatica
    • Labels:
      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[].

        Issue Links

          Activity

          Hide
          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.

          Show
          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.
          Hide
          elserj Josh Elser added a comment -

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

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

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

          Is StringAccessorTest called?

          Show
          julianhyde Julian Hyde added a comment - If the underlying data is represented using byte[], why is a StringAccessor being created? Is StringAccessorTest called?
          Hide
          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.

          Show
          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.
          Hide
          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.

          Show
          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.
          Hide
          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.

          Show
          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.
          Hide
          julianhyde Julian Hyde added a comment -
          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/6f326d03 . Thanks for the patch, Josh Elser !
          Hide
          jcamachorodriguez Jesus Camacho Rodriguez added a comment -

          Resolved in release 1.5.0 (2015-11-10)

          Show
          jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.5.0 (2015-11-10)

            People

            • Assignee:
              elserj Josh Elser
              Reporter:
              elserj Josh Elser
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development