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

Avro Schema parser treats Avro float type as Java Double for default values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.8.1
    • 1.9.0, 1.8.2
    • java
    • None

    Description

      The following code snippet in the Schema class shows that we explicitly treat Avro FLOAT and DOUBLE as a Java Double.

      JsonNode defaultValue = field.get("default");
      if (defaultValue != null
          && (Type.FLOAT.equals(fieldSchema.getType())
              || Type.DOUBLE.equals(fieldSchema.getType()))
          && defaultValue.isTextual())
        defaultValue =
          new DoubleNode(Double.valueOf(defaultValue.getTextValue()));
      

      Jackson has support for FloatNode so why don't we use that?

      This is a problem when someone calls Schema.Field#defaultVal for an Avro field with Avro type FLOAT and they try to typecast the object to a Java float.

      Attachments

        Issue Links

          Activity

            People

              gszadovszky Gabor Szadovszky
              amok Andy Mok
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: