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

When parsing a schema the logical type is not properly set for the result instance

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 1.9.0
    • Fix Version/s: 1.9.0
    • Component/s: java
    • Labels:
      None

      Description

      When the following schema is parsed:

      Schema schema = new Schema.Parser().parse("{ \"name\": \"test\", \"type\": \"record\", \"fields\": [{ \"name\": \"time\", \"type\": { \"type\": \"long\", \"logicalType\": \"MY_TIMESTAMP\" }}]}");
      

      the `logicalType` is not properly initialized for the schema object of the `time` field. This means that:

      Schema timeSchema = schema.getField("time").schema();
      
      assert(null == timeSchema.getLogicalType());
      assert(null != timeSchema.getObjectProp(LogicalType.LOGICAL_TYPE_PROP))
      

      The private schema value representing the logical type is still `null`. However, the property map is properly filled with a `LOGICAL_TYPE_PROP`.

      Such a schema is unusable because the client of the library cannot fix the logical type afterwards.

      myLogicalType.addToSchema(timeSchema); // BOOM
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              terusus Teodor Kostov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: