Hello!

I'm really enthusiastic about having a "selector" standard for both
Avro schemas and Avro data -- this is a compelling feature that would
have simplified my life many times in the past!

I like the avpath / jspath syntax, but that might be bias because I've
used it in the past (I should disclose that I participated in a fork
maintained publicly by Talend years ago!).   Just to brainstorm
alternatives, I suppose alternatives could include trying to align to
other existing standards that looks like jsonpath is or even something
like jq syntax.

Your use case of improved error messages is a great starting point,
since it would only require generating an AvroPath from a known schema
or data, and I think it would be helpful across SDKs to use the same
format.  A good first step might be just to adopt and implement your
proposal with the three predicates right away in the Java SDK (without
calling it "our standard") to see how it goes, and open the discussion
again from there!

All my best and thanks again for your thoughts on this,  Ryan

[avpath]: https://github.com/Talend/avpath/
[jsonpath]: https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base/
[jq]: https://stedolan.github.io/jq/tutorial/

On Tue, Feb 15, 2022 at 12:31 AM r <[email protected]> wrote:
>
> 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?

Reply via email to