Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package org.opensearch.sql.opensearch.storage.scan;

import com.google.common.collect.ImmutableList;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -18,6 +20,7 @@
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.AbstractRelNode;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.rules.CoreRules;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollations;
Expand Down Expand Up @@ -63,6 +66,8 @@
import org.opensearch.sql.opensearch.storage.scan.context.PushDownType;
import org.opensearch.sql.opensearch.storage.scan.context.RareTopDigest;

import static java.util.Collections.emptyList;

/** The logical relational operator representing a scan of an OpenSearchIndex type. */
@Getter
public class CalciteLogicalIndexScan extends AbstractCalciteIndexScan {
Expand Down Expand Up @@ -279,15 +284,12 @@ public CalciteLogicalIndexScan pushDownProject(List<Integer> selectedColumns) {
requestBuilder -> requestBuilder.pushDownProjectStream(projectedFields.stream());
}
// Create a Project RelNode for Substrait conversion
org.apache.calcite.rex.RexBuilder rexBuilder = getCluster().getRexBuilder();
List<org.apache.calcite.rex.RexNode> projects = new java.util.ArrayList<>();
RexBuilder rexBuilder = getCluster().getRexBuilder();
List<RexNode> projects = new ArrayList<>();
for (int columnIndex : selectedColumns) {
projects.add(rexBuilder.makeInputRef(this, columnIndex));
}
org.apache.calcite.rel.core.Project projectRelNode =
org.apache.calcite.rel.logical.LogicalProject.create(
this, java.util.Collections.emptyList(), projects, newSchema);

Project projectRelNode = LogicalProject.create(this, emptyList(), projects, newSchema);
newScan.pushDownContext.add(PushDownType.PROJECT, newSchema.getFieldNames(), action, projectRelNode);
return newScan;
}
Expand Down Expand Up @@ -333,7 +335,7 @@ public CalciteLogicalIndexScan pushDownSortAggregateMeasure(Sort sort) {
aggAction.rePushDownSortAggMeasure(
sort.getCollation().getFieldCollations(), rowType.getFieldNames());
Object digest = sort.getCollation().getFieldCollations();
newScan.pushDownContext.add(PushDownType.SORT_AGG_METRICS, digest, newAction);
newScan.pushDownContext.add(PushDownType.SORT_AGG_METRICS, digest, newAction, sort);
return newScan;
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
Expand Down
Loading