Skip to content

org.msgpack.core.MessageTypeCastException for DECIMAL type #25

@weasellin

Description

@weasellin

The org.msgpack.core.MessageTypeCastException would be thrown when the results of the td query contains DECIMAL type.

This exception cause by the following reason.

Since the DECIMAL type "columns" are interpreted as embulks DOUBLE type,
https://github.com/treasure-data/embulk-input-td/blob/v0.2.3/src/main/java/org/embulk/input/td/TdInputPlugin.java#L233

however the DECIMAL type "data fields" are packed and unpacked as MessagePack's String type.

ex.
This query

SELECT * FROM ( VALUES DECIMAL '0.0' ) AS t (dec)

would yeid the msgpack serialized bytes sequence 0x91 0xA3 0x30 0x2E 0x30,
and deserialized as fixstr type (first byte 0xa0 - 0xbf)

And for the ImmutableStringValue, it doesn't support asFloatValue() and will end up with throwing the MessageTypeCastException.

The following is the testing environment I used to reproduce the issue.

  • Embulk v0.9.22
  • plugin embulk-input-td (0.2.3)
  • td-client version: 0.9.0
  • config.yml
in:
  type: td
  apikey: [MY_API_KEY]
  database: [MY_DB]
  query: |
    SELECT * FROM ( VALUES DECIMAL '0.0' ) AS t (dec)

out:
  type: stdout
  • run embulk preview config.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions