Consider standardizing the exact behaviour of sub-
and pipe-expressions
#113
Replies: 2 comments 2 replies
-
See: #114 |
Beta Was this translation helpful? Give feedback.
-
Evaluation of Pipe Expressions
AbstractThis JEP introduces changes that outline the exact intended behaviour of evaluating a MotivationSub Expression EvaluationThe specification for
This is slightly ambiguous, as many compliance tests expect the result to be
Pipe Expression EvaluationIn contrast, however, it seems intuitive for
Which means that the evaluation should still happens if the left-hand-side is SpecificationSub ExpressionsThe paragraph on sub expressions in the specification will be updated as follows, with changes outlined in bold: A subexpression is evaluted as follows:
In pseudocode:
Pipe ExpressionsLikewise the paragraph on pipe expressions in the specification will be updated as follows: A pipe expression combines two expressions, separated by the | character. It is similar to a sub-expression with
In pseudocode:
Example
ComplianceThe |
Beta Was this translation helpful? Give feedback.
-
Ambiguities in the specification
Sub-Expressions
The specification outlines the behaviour of
sub-expressions
like this:However, compliance tests disagree and evaluate
search( `null`.[@], {} ) -> null
.So the real pseudo code would look like so:
The canonical JavaScript and Python implementations behave accordingly.
Pipe Expressions
The specification also touches on the fact that a
pipe-expression
is similar 🤔 tosub-expression
. The only difference being in its handling of the projections and the kinds of expressions allowed on its right-hand-side.My belief is that a
pipe-expression
should behave a bit differently, however. In fact, I think it should behave as the original pseudo code forsub-expression
was written:I believe JMESPath should evaluate
search( `null` | [@], {} ) -> [ null ]
However, the JavaScript and Python implementations disagree and behave exactly as evaluating a
sub-expression
.Alternative and Standard Behaviour
The goal of JMESPath Community is to improve on JMESPath. For this to gain traction, I think we should strive for compatibility until we have a good track record of improvements, governance and stewardship of the language.
However, I think we have a small window of opportunity.
In fact the compliance tests do not cover the
`null` | [@]
case so maybe we can standardize on any behaviour we want.My question to the community is to garner feedback and land on a consensus for how
pipe-expression
should be standardized.1 vote ·
Beta Was this translation helpful? Give feedback.
All reactions