[feature] Support map atomization in XQuery 4.0#6259
Open
joewiz wants to merge 2 commits into
Open
Conversation
In XQuery 3.1, maps are function items and cannot be atomized (FOTY0013). In XQuery 4.0, maps are a distinct type whose atomization returns the concatenation of the atomized values of their entries. This change adds version-gated map atomization so that ~103 XQTS QT4 tests that fail with FOTY0013 can pass when combined with the XQ4 parser support (v2/xq4-parser-extensions). - AbstractMapType: override atomize(), add isXq4Atomizable() and atomizeValues() for XQ4 semantics - Atomize: expand XQ4 maps in static atomize(Sequence), paralleling ArrayType.flatten() for arrays - ConcatExpr: allow XQ4 maps in string concatenation instead of unconditionally throwing FOTY0013 XQ 3.1 behavior is unchanged: maps still raise FOTY0013. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
reinhapa
requested changes
Apr 25, 2026
Comment on lines
+82
to
+84
| if (single instanceof AbstractMapType && ((AbstractMapType) single).isXq4Atomizable()) { | ||
| return ((AbstractMapType) single).atomizeValues(); | ||
| } |
Member
There was a problem hiding this comment.
Use direct cast using local variable here:
Suggested change
| if (single instanceof AbstractMapType && ((AbstractMapType) single).isXq4Atomizable()) { | |
| return ((AbstractMapType) single).atomizeValues(); | |
| } | |
| if (single instanceof AbstractMapType mapType && mapType.isXq4Atomizable()) { | |
| return mapType.atomizeValues(); | |
| } |
Comment on lines
+93
to
+94
| if (next instanceof AbstractMapType && ((AbstractMapType) next).isXq4Atomizable()) { | ||
| result.addAll(((AbstractMapType) next).atomizeValues()); |
Member
There was a problem hiding this comment.
Same as above
Suggested change
| if (next instanceof AbstractMapType && ((AbstractMapType) next).isXq4Atomizable()) { | |
| result.addAll(((AbstractMapType) next).atomizeValues()); | |
| if (next instanceof AbstractMapType mapType && mapType.isXq4Atomizable()) { | |
| result.addAll(mapType.atomizeValues()); |
Comment on lines
+71
to
+72
| if (item instanceof AbstractMapType && ((AbstractMapType) item).isXq4Atomizable()) { | ||
| final Sequence atomized = ((AbstractMapType) item).atomizeValues(); |
Member
There was a problem hiding this comment.
Same here
Suggested change
| if (item instanceof AbstractMapType && ((AbstractMapType) item).isXq4Atomizable()) { | |
| final Sequence atomized = ((AbstractMapType) item).atomizeValues(); | |
| if (item instanceof AbstractMapType mapType && mapType.isXq4Atomizable()) { | |
| final Sequence atomized = mapType.atomizeValues(); |
Use Java 16+ pattern-matching instanceof to eliminate redundant casts in Atomize.java and ConcatExpr.java. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
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
err:FOTY0013when atomizing map resultsWhat Changed
AbstractMapType.javaisXq4Atomizable()— version gate: returnstruewhencontext.getXQueryVersion() >= 40atomizeValues()— iterates all map entries, atomizes each value, returns flatSequenceatomize()override — for XQ4 single-entry maps returns the atomized value; for XQ 3.1 throws FOTY0013Atomize.javaatomize(Sequence)to detect XQ4 maps and expand them viaatomizeValues()before individual item atomization — same pattern asArrayType.flatten()for arraysConcatExpr.javaSpec References
Test Plan
maps.xqm:no-atomizationstill expects error (maps not atomizable in 3.1)cast-constructor.xqm:atomize-map-failsstill expects FOTY0013next-v3integration with XQ4 parser)Note: On develop, the
isXq4Atomizable()check always returnsfalsesince the XQ4 parser support (v2/xq4-parser-extensions) is not yet merged. The code path activates when integrated intonext-v3.🤖 Generated with Claude Code