Implement XQuery 4.0 FilterExprAM (?[expr]) for arrays and maps#6211
Open
joewiz wants to merge 1 commit intoeXist-db:developfrom
Open
Implement XQuery 4.0 FilterExprAM (?[expr]) for arrays and maps#6211joewiz wants to merge 1 commit intoeXist-db:developfrom
?[expr]) for arrays and maps#6211joewiz wants to merge 1 commit intoeXist-db:developfrom
Conversation
4 tasks
a36844a to
f36b12f
Compare
Add the array/map filter expression from the QT4 specification.
The ?[expr] operator filters array members or map entries by
evaluating a predicate with each member/value as the context item.
Examples:
[1, 2, 3, 4, 5]?[. > 3] -> [4, 5]
map{"a":1, "b":2, "c":3}?[. > 1] -> map{"b":2, "c":3}
Parser (XQuery.g):
- Add FILTER_AM token
- Add filterExprAM rule: QUESTION LPPAREN exprSingle RPPAREN
- Disambiguate from lookup: ?[ is FilterExprAM, ?name is lookup
Tree Walker (XQueryTree.g):
- Add filterExprAM rule that creates FilterExprAM expression
- Chain in postfixExpr alongside lookup and predicate
FilterExprAM.java:
- Extends AbstractExpression
- For arrays: iterates members, evaluates predicate with each as
context item, keeps members where EBV is true
- For maps: iterates entries, evaluates predicate with each value
as context item, keeps entries where EBV is true
- XPTY0004 for non-array/map targets
17 XQSuite tests (993/993 total XQuery3Tests pass, 0 regressions).
Spec: https://qt4cg.org/specifications/xquery-40/xpath-40-xquery-40.html#id-filter-am
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f36b12f to
9378360
Compare
Member
Author
|
[This response was co-authored with Claude Code. -Joe] CI state: 5/9 checks pass. Of the 4 failures:
Dependencies: None. This PR is Wave 1 — it can be reviewed and merged independently. For full context on all 7.0 PRs and the merge order, see the Reviewer Guide. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the
?[expr]filter syntax for arrays and maps per XQuery 4.0. Includes grammar changes (XQuery.g, XQueryTree.g) and expression class.Spec References
Tests
Test plan
🤖 Generated with Claude Code