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

Prettify the json dumped during exceptions while validating a writer/reader schema

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.3.3
    • 1.5.0
    • java, python
    • None
    • Avro-Trunk

    • Reviewed
    • Print out a pretty output when dumping schema text during an exception.
    • schema exceptions

    Description

      Right now the exception that's thrown when a reader and written schema don't match (while reading a file), looks like this:

      Found {"type":"record","name":"Test","fields":[{"name":"stringField","type":"string"},{"name":"longField","type":"long"}]}, expecting {"type":"record","name":"Test1","fields":[{"name":"stringField","type":"string"},{"name":"longField","type":"long"}]}
      

      While this is perfectly okay for small schema with a few fields, it gets hard to debug for complex and large ones.

      The attached patch changes the exception message to look like:

      Found {
        "type" : "record",
        "name" : "Test",
        "fields" : [ {
          "name" : "stringField",
          "type" : "string"
        }, {
          "name" : "longField",
          "type" : "long"
        } ]
      }, expecting {
        "type" : "record",
        "name" : "Test1",
        "fields" : [ {
          "name" : "stringField",
          "type" : "string"
        }, {
          "name" : "longField",
          "type" : "long"
        } ]
      }
      

      P.s. Ideally a diff-like message would help too, but its mileage may vary. I guess with the pretty output printed, a user may easily do a diff (since they now have newlines), so us providing this is not really needed.

      Attachments

        1. avro.java.schema.pretty.r1.diff
          1 kB
          Harsh J
        2. avro.py.schema.pretty.r1.diff
          1 kB
          Harsh J
        3. avro.schema.pretty.r2.diff
          2 kB
          Harsh J
        4. avro.schema.pretty.r3.diff
          2 kB
          Harsh J
        5. avro.schema.pretty.r4.diff
          1 kB
          Harsh J
        6. avro.schema.pretty.r5.diff
          3 kB
          Harsh J

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            qwertymaniac Harsh J
            qwertymaniac Harsh J
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1m
                1m
                Remaining:
                Remaining Estimate - 1m
                1m
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment