use of org.apache.ignite.internal.sql.engine.rel.IgniteTableSpool in project ignite-3 by apache.
the class FilterSpoolMergeToSortedIndexSpoolRule method onMatch.
/**
* {@inheritDoc}
*/
@Override
public void onMatch(RelOptRuleCall call) {
final IgniteFilter filter = call.rel(0);
final IgniteTableSpool spool = call.rel(1);
RelOptCluster cluster = spool.getCluster();
RelTraitSet trait = spool.getTraitSet();
CorrelationTrait filterCorr = TraitUtils.correlation(filter);
if (filterCorr.correlated()) {
trait = trait.replace(filterCorr);
}
RelNode input = spool.getInput();
IndexConditions idxCond = RexUtils.buildSortedIndexConditions(cluster, TraitUtils.collation(input), filter.getCondition(), spool.getRowType(), null);
if (nullOrEmpty(idxCond.lowerCondition()) && nullOrEmpty(idxCond.upperCondition())) {
return;
}
RelCollation collation = TraitUtils.createCollation(idxCond.keys());
RelNode res = new IgniteSortedIndexSpool(cluster, trait.replace(collation), convert(input, input.getTraitSet().replace(collation)), collation, filter.getCondition(), idxCond);
call.transformTo(res);
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteTableSpool in project ignite-3 by apache.
the class FilterSpoolMergeToHashIndexSpoolRule method onMatch.
/**
* {@inheritDoc}
*/
@Override
public void onMatch(RelOptRuleCall call) {
final IgniteFilter filter = call.rel(0);
final IgniteTableSpool spool = call.rel(1);
RelOptCluster cluster = spool.getCluster();
RelTraitSet trait = spool.getTraitSet();
CorrelationTrait filterCorr = TraitUtils.correlation(filter);
if (filterCorr.correlated()) {
trait = trait.replace(filterCorr);
}
final RelNode input = spool.getInput();
List<RexNode> searchRow = RexUtils.buildHashSearchRow(cluster, filter.getCondition(), spool.getRowType());
if (nullOrEmpty(searchRow)) {
return;
}
RelNode res = new IgniteHashIndexSpool(cluster, trait.replace(RelCollations.EMPTY), input, searchRow, filter.getCondition());
call.transformTo(res);
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteTableSpool in project ignite-3 by apache.
the class TableSpoolPlannerTest method tableSpoolDistributed.
/**
* TableSpoolDistributed.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*
* @throws Exception If failed.
*/
@Test
public void tableSpoolDistributed() throws Exception {
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
TestTable t0 = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("JID", f.createJavaType(Integer.class)).add("VAL", f.createJavaType(String.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "T0", "hash");
}
};
TestTable t1 = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("JID", f.createJavaType(Integer.class)).add("VAL", f.createJavaType(String.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "T1", "hash");
}
};
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
publicSchema.addTable("T0", t0);
publicSchema.addTable("T1", t1);
String sql = "select * " + "from t0 " + "join t1 on t0.jid > t1.jid";
IgniteRel phys = physicalPlan(sql, publicSchema, "MergeJoinConverter", "NestedLoopJoinConverter", "FilterSpoolMergeRule");
assertNotNull(phys);
IgniteTableSpool tblSpool = findFirstNode(phys, byClass(IgniteTableSpool.class));
assertNotNull(tblSpool, "Invalid plan:\n" + RelOptUtil.toString(phys));
checkSplitAndSerialization(phys, publicSchema);
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteTableSpool in project ignite-3 by apache.
the class TraitUtils method convertRewindability.
/**
* Convert rewindability. TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@Nullable
public static RelNode convertRewindability(RewindabilityTrait toTrait, RelNode rel) {
RewindabilityTrait fromTrait = rewindability(rel);
if (fromTrait.satisfies(toTrait)) {
return rel;
}
RelTraitSet traits = rel.getTraitSet().replace(toTrait).replace(CorrelationTrait.UNCORRELATED);
return new IgniteTableSpool(rel.getCluster(), traits, Spool.Type.LAZY, RelOptRule.convert(rel, rel.getTraitSet().replace(CorrelationTrait.UNCORRELATED)));
}
Aggregations