[BugFix] Fix appendcol subquery cannot resolve MAP sub-paths after spath (#5186)#5304
[BugFix] Fix appendcol subquery cannot resolve MAP sub-paths after spath (#5186)#5304qianheng-aws wants to merge 1 commit intoopensearch-project:mainfrom
Conversation
…ath (opensearch-project#5186) When spath auto-extract transforms a STRING field to MAP, the appendcol subquery could not resolve dotted paths like doc.user.city because it operated on the raw source table where doc is still STRING. Root cause: visitAppendCol attached only the raw Relation to the subsearch via getRelation()+transformPlanToAttachChild(), missing schema-transforming commands like spath. Additionally, the PPLQueryDataAnonymizer.visitAppendCol runs first and attaches a raw Relation, and Relation.attach() is a no-op, so subsequent attachment attempts silently failed. Fix: buildAppendColSubsearchSource() collects SPath nodes from the main plan chain and builds a new SPath->Relation chain. The subsearch attachment walks to find the parent of any existing Relation and re-attaches with the full source chain including spath transformations. Signed-off-by: Heng Qian <qianheng@amazon.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Heng Qian <qianheng@amazon.com>
Decision LogRoot Cause: Two interacting issues caused the bug:
Approach:
Alternatives Rejected:
Pitfalls:
Things to Watch:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Description
When
spathauto-extract transforms a STRING field to MAP, theappendcolsubquery could not resolve dotted MAP paths likedoc.user.city. The subquery failed withINTERNAL_ITEM function expects {[ARRAY,INTEGER]|[STRUCT,ANY]}, but got [STRING,STRING].Root cause:
visitAppendColattached only the rawRelationto the subsearch viagetRelation()+transformPlanToAttachChild(), missing schema-transforming commands likespath. Additionally,PPLQueryDataAnonymizer.visitAppendColruns first and attaches a rawRelation, andRelation.attach()is a no-op, so subsequent attachment attempts in the visitor silently failed.Fix:
buildAppendColSubsearchSource()collectsSPathnodes from the main plan chain and builds a newSPath -> Relationchain. The subsearch attachment walks to find the parent of any existingRelationand re-attaches with the full source chain including spath transformations.Related Issues
Resolves #5186
Check List
-s)spotlessCheckpassed.g4files synced (N/A - no grammar changes)