avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AVRO-642) Prettify the json dumped during exceptions while validating a writer/reader schema
Date Mon, 25 Oct 2010 20:36:22 GMT

    [ https://issues.apache.org/jira/browse/AVRO-642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924711#action_12924711
] 

Doug Cutting commented on AVRO-642:
-----------------------------------

Here's the python error I see for this.

{code}

ERROR: test_type_exception (test_io.TestIO)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/cutting/src/avro/trunk/lang/py/build/test/test_io.py", line 334, in test_type_exception
    self.assertRaises(io.AvroTypeException, write_datum, datum_to_write, writers_schema)
  File "/usr/lib/python2.6/unittest.py", line 336, in failUnlessRaises
    callableObj(*args, **kwargs)
  File "/home/cutting/src/avro/trunk/lang/py/build/test/test_io.py", line 119, in write_datum
    datum_writer.write(datum, encoder)
  File "/home/cutting/src/avro/trunk/lang/py/build/src/avro/io.py", line 750, in write
    raise AvroTypeException(self.writers_schema, datum)
  File "/home/cutting/src/avro/trunk/lang/py/build/src/avro/io.py", line 77, in __init__
    pretty_expected = json.dumps(json.loads(str(expected_schema)), indent=2)
NameError: global name 'json' is not defined
{code}

> Prettify the json dumped during exceptions while validating a writer/reader schema
> ----------------------------------------------------------------------------------
>
>                 Key: AVRO-642
>                 URL: https://issues.apache.org/jira/browse/AVRO-642
>             Project: Avro
>          Issue Type: Improvement
>          Components: java, python
>    Affects Versions: 1.3.3
>         Environment: Avro-Trunk
>            Reporter: Harsh J Chouraria
>            Assignee: Harsh J Chouraria
>            Priority: Minor
>             Fix For: 1.5.0
>
>         Attachments: avro.java.schema.pretty.r1.diff, avro.py.schema.pretty.r1.diff,
avro.schema.pretty.r2.diff
>
>   Original Estimate: 0.02h
>  Remaining Estimate: 0.02h
>
> Right now the exception that's thrown when a reader and written schema don't match (while
reading a file), looks like this:
> {noformat}
> 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"}]}
> {noformat}
> 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:
> {noformat}
> 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"
>   } ]
> }
> {noformat}
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message