Hi,
I've been working on a PR that (in my opinion at least?) improves the
readability of serialization errors out of (java) avro -
https://github.com/apache/avro/pull/1526 (
https://issues.apache.org/jira/browse/AVRO-3375)
for tracing the location of a bad piece of data within a root object i've
been using a syntax like
"rootObject.arrayProp[6].simpleProp.mapProp("key").unionProp[unionBranch]"
etc.
on the PR discussions Ryan pointed out this looks very much like (a small
subset of) AvroPath - https://issues.apache.org/jira/browse/AVRO-992 - an
old proposal for a jspath-like expression language for avro.
I dont know if anyone has any interest in reviving that proposal, but I'd
like to propose at least a small subset of the path elements needed to
localize errors.
using jspath as a baseline reference (https://github.com/dfilatov/jspath) i
see 1 "location path" and 3 predicates that would be required:
- Location Path - of the form ".propertyName". represents the property
of a record. jspath has more advanced "..propName" and wildcard support,
but those are not needed for localizing errors.
- ArrayPositionPredicate - of the form "[i]" where i is a non-negative
long.
- MapKeyPredicate - of the form "("key")" where "key" is a string and
always quoted (as avro only allows for non-null string keys in maps). in
terms of implementation key==null could be used to indicates an invalid map
key
- UnionTypePredicate - of the form "[typeName]" where typeName is
unquoted. represents a branch of a union.
there exists a jspath-inspired implementation of avro path (
https://github.com/dcaoyuan/avpath) though it appears to no longer be
maintained and, being scala, is not easy to integrate into the java
codebase.
any opinions on at least standardizing on the above syntax for errors?