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

Schema parsing does not work for non-record types with logicalType

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • 1.9.0
    • None
    • java
    • None

    Description

      Parsing the following schema fails:

      new Schema.Parser().parse("{ \"name\": \"test\", \"type\": { \"type\": \"long\", \"logicalType\": \"MY_TIMESTAMP\" }}")
      

      with the following exception:

      No type: {"name":"test","type":{"type":"long","logicalType":"MY_TIMESTAMP"}}
      org.apache.avro.SchemaParseException: No type: {"name":"test","type":{"type":"long","logicalType":"MY_TIMESTAMP"}}
      	at org.apache.avro.Schema.getRequiredText(Schema.java:1725)
      	at org.apache.avro.Schema.parse(Schema.java:1576)
      	at org.apache.avro.Schema$Parser.parse(Schema.java:1366)
      	at org.apache.avro.Schema$Parser.parse(Schema.java:1354)
      

      The complex type cannot be properly parsed because it is not a simple string but a JSON object. Hence when calling `jsonNode.textValue()` the result is null. Check `getOptionalText(...)` for more information.

      When supplying logical types it should be possible to parse a simple schema.

      Attachments

        Activity

          People

            Unassigned Unassigned
            terusus Teodor Kostov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: