Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1099

Int / Float cannot be decoded

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3
    • 1.7.0
    • java
    • Mac OS X 10.7.3. Eclipse IDE for Java EE Developers 1.4.2.20120213

    • int double zero 0

    Description

      I am currently using a JSON library that is encoding 0 for a double to "0" instead of "0.0", without the quotes. First, I feel that "0" is a perfectly valid value for 0 as a double. But, I tried to code around it by changing the "type" of the field to "["double", "int"]", without the quotes and it is giving me this error:

      Exception in thread "main" org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_NUMBER_INT
      at org.apache.avro.io.JsonDecoder.error(JsonDecoder.java:697)
      at org.apache.avro.io.JsonDecoder.readIndex(JsonDecoder.java:441)
      at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:229)
      at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
      at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:206)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:148)
      at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:173)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:144)
      at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:135)

      If I change it to just "int", then it works for a few records until it reaches a double.

      Thank you,

      John

      Attachments

        1. AVRO-1099.patch
          4 kB
          Doug Cutting

        Activity

          People

            cutting Doug Cutting
            jojenki John Jenkins
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: