Skip to content

Commit

Permalink
IGNITE-12455 Fix IGNORE node.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandasch committed Oct 17, 2023
1 parent cd3082c commit 02bc10c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.stream.Collectors;
import com.google.common.primitives.Primitives;
import org.apache.calcite.rel.RelDistribution;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeField;
import org.apache.calcite.rex.RexCall;
Expand All @@ -45,9 +44,11 @@
import org.apache.ignite.internal.processors.query.calcite.prepare.Fragment;
import org.apache.ignite.internal.processors.query.calcite.prepare.IgniteRelShuttle;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteIndexScan;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteReceiver;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteSender;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteTableScan;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteTrimExchange;
import org.apache.ignite.internal.processors.query.calcite.rel.ProjectableFilterableTableScan;
import org.apache.ignite.internal.processors.query.calcite.schema.CacheTableDescriptor;
import org.apache.ignite.internal.processors.query.calcite.schema.IgniteTable;
Expand Down Expand Up @@ -81,6 +82,20 @@ public PartitionExtractor(IgniteTypeFactory typeFactory) {
return rel;
}

/** {@inheritDoc} */
@Override public IgniteRel visit(IgniteTrimExchange rel) {
stack.push(PartitionAllNode.IGNORE);

return rel;
}

/** {@inheritDoc} */
@Override public IgniteRel visit(IgniteReceiver rel) {
stack.push(PartitionAllNode.IGNORE);

return rel;
}

/** {@inheritDoc} */
@Override protected IgniteRel processNode(IgniteRel rel) {
IgniteRel res = super.processNode(rel);
Expand All @@ -106,7 +121,7 @@ public PartitionNode go(Fragment fragment) {
if (fragment.mapping() == null || !fragment.mapping().colocated())
return PartitionAllNode.INSTANCE;

visit(fragment.root());
processNode(fragment.root());

if (stack.isEmpty())
return PartitionAllNode.INSTANCE;
Expand All @@ -122,13 +137,7 @@ private void processScan(IgniteRel rel) {

IgniteTable tbl = rel.getTable().unwrap(IgniteTable.class);

if (tbl.distribution().function().type() == RelDistribution.Type.BROADCAST_DISTRIBUTED) {
stack.push(PartitionAllNode.INSTANCE_REPLICATED);

return;
}

if (tbl.distribution().getKeys().size() != 1) {
if (!tbl.distribution().function().affinity() || tbl.distribution().getKeys().size() != 1) {
stack.push(PartitionAllNode.INSTANCE);

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

/** */
public class PartitionAllNode implements PartitionNode {
/** */
public static final PartitionAllNode INSTANCE_REPLICATED = new PartitionAllNode(true);
/** Exclude this node from partition calculation if other nodes present in {@link PartitionParameterNode }. */
public static final PartitionAllNode IGNORE = new PartitionAllNode(true);

/** */
public static final PartitionAllNode INSTANCE = new PartitionAllNode(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private PartitionOperandNode(Operand op, List<PartitionNode> operands) {

if (op == Operand.AND) {
for (PartitionNode operand : operands) {
if (operand == PartitionAllNode.INSTANCE_REPLICATED)
if (operand == PartitionAllNode.IGNORE)
continue;

Collection<Integer> parts = operand.apply(ctx);
Expand All @@ -59,7 +59,7 @@ private PartitionOperandNode(Operand op, List<PartitionNode> operands) {
}
else {
for (PartitionNode operand: operands) {
if (operand == PartitionAllNode.INSTANCE_REPLICATED)
if (operand == PartitionAllNode.IGNORE)
continue;

Collection<Integer> parts = operand.apply(ctx);
Expand Down

0 comments on commit 02bc10c

Please sign in to comment.