diff --git a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/CatalystQueryPlanVisitor.java b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/CatalystQueryPlanVisitor.java index 44f8a6401..45ddc6809 100644 --- a/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/CatalystQueryPlanVisitor.java +++ b/ppl-spark-integration/src/main/java/org/opensearch/sql/ppl/CatalystQueryPlanVisitor.java @@ -277,8 +277,8 @@ public LogicalPlan visitAppendCol(AppendCol node, CatalystPlanContext context) { // Duplicate the relation clause from main-search to sub-search. AppendColCatalystUtils.appendRelationClause(node.getSubSearch(), context.getRelations()); - context.apply(left -> { + // Apply an additional projection layer on sub-search to provide natural order. LogicalPlan subSearch = subSearchNode.accept(this, context); var subSearchWithRowNumber = AppendColCatalystUtils.getRowNumStarProjection(context, subSearch, TABLE_RHS); @@ -294,7 +294,6 @@ public LogicalPlan visitAppendCol(AppendCol node, CatalystPlanContext context) { Optional.of(new EqualTo(t1Attr, t2Attr)), new Join.JoinHint()); - // Remove the APPEND_ID and duplicated field on T1 if override option present. if (node.override) { List getoverridedlist = AppendColCatalystUtils.getOverridedList(subSearchWithRowNumber, TABLE_LHS);