use of org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory 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.type.IgniteTypeFactory in project ignite-3 by apache.
the class BaseAggregateTest method min.
/**
* Min.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@ParameterizedTest
@EnumSource
public void min(TestAggregateType testAgg) {
ExecutionContext<Object[]> ctx = executionContext();
IgniteTypeFactory tf = ctx.getTypeFactory();
RelDataType rowType = TypeUtils.createRowType(tf, int.class, int.class);
ScanNode<Object[]> scan = new ScanNode<>(ctx, rowType, Arrays.asList(row(0, 200), row(1, 300), row(1, 1400), row(0, 1000)));
AggregateCall call = AggregateCall.create(SqlStdOperatorTable.MIN, false, false, false, ImmutableIntList.of(1), -1, RelCollations.EMPTY, tf.createJavaType(int.class), null);
List<ImmutableBitSet> grpSets = List.of(ImmutableBitSet.of(0));
RelDataType aggRowType = TypeUtils.createRowType(tf, int.class);
SingleNode<Object[]> aggChain = createAggregateNodesChain(testAgg, ctx, grpSets, call, rowType, aggRowType, rowFactory(), scan);
RootNode<Object[]> root = new RootNode<>(ctx, aggRowType);
root.register(aggChain);
assertTrue(root.hasNext());
assertArrayEquals(row(0, 200), root.next());
assertArrayEquals(row(1, 300), root.next());
assertFalse(root.hasNext());
}
use of org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory in project ignite-3 by apache.
the class BaseAggregateTest method max.
/**
* Max.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@ParameterizedTest
@EnumSource
public void max(TestAggregateType testAgg) {
ExecutionContext<Object[]> ctx = executionContext();
IgniteTypeFactory tf = ctx.getTypeFactory();
RelDataType rowType = TypeUtils.createRowType(tf, int.class, int.class);
ScanNode<Object[]> scan = new ScanNode<>(ctx, rowType, Arrays.asList(row(0, 200), row(1, 300), row(1, 1400), row(0, 1000)));
AggregateCall call = AggregateCall.create(SqlStdOperatorTable.MAX, false, false, false, ImmutableIntList.of(1), -1, RelCollations.EMPTY, tf.createJavaType(int.class), null);
List<ImmutableBitSet> grpSets = List.of(ImmutableBitSet.of(0));
RelDataType aggRowType = TypeUtils.createRowType(tf, int.class);
SingleNode<Object[]> aggChain = createAggregateNodesChain(testAgg, ctx, grpSets, call, rowType, aggRowType, rowFactory(), scan);
RootNode<Object[]> root = new RootNode<>(ctx, aggRowType);
root.register(aggChain);
assertTrue(root.hasNext());
assertArrayEquals(row(0, 1000), root.next());
assertArrayEquals(row(1, 1400), root.next());
assertFalse(root.hasNext());
}
use of org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory in project ignite-3 by apache.
the class BaseAggregateTest method avg.
/**
* Avg.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@ParameterizedTest
@EnumSource
public void avg(TestAggregateType testAgg) {
ExecutionContext<Object[]> ctx = executionContext();
IgniteTypeFactory tf = ctx.getTypeFactory();
RelDataType rowType = TypeUtils.createRowType(tf, int.class, int.class);
ScanNode<Object[]> scan = new ScanNode<>(ctx, rowType, Arrays.asList(row(0, 200), row(1, 300), row(1, 1300), row(0, 1000)));
AggregateCall call = AggregateCall.create(SqlStdOperatorTable.AVG, false, false, false, ImmutableIntList.of(1), -1, RelCollations.EMPTY, tf.createJavaType(int.class), null);
List<ImmutableBitSet> grpSets = List.of(ImmutableBitSet.of(0));
RelDataType aggRowType = TypeUtils.createRowType(tf, int.class);
SingleNode<Object[]> aggChain = createAggregateNodesChain(testAgg, ctx, grpSets, call, rowType, aggRowType, rowFactory(), scan);
RootNode<Object[]> root = new RootNode<>(ctx, aggRowType);
root.register(aggChain);
assertTrue(root.hasNext());
assertArrayEquals(row(0, 600), root.next());
assertArrayEquals(row(1, 800), root.next());
assertFalse(root.hasNext());
}
use of org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory in project ignite-3 by apache.
the class BaseAggregateTest method sumOnDifferentRowsCount.
/**
* SumOnDifferentRowsCount.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@ParameterizedTest
@EnumSource
public void sumOnDifferentRowsCount(TestAggregateType testAgg) {
int bufSize = Commons.IN_BUFFER_SIZE;
int[] grpsCount = { 1, bufSize / 2, bufSize, bufSize + 1, bufSize * 4 };
int[] rowsInGroups = { 1, 5, bufSize };
for (int grps : grpsCount) {
for (int rowsInGroup : rowsInGroups) {
log.info("Check: [grps=" + grps + ", rowsInGroup=" + rowsInGroup + ']');
ExecutionContext<Object[]> ctx = executionContext();
IgniteTypeFactory tf = ctx.getTypeFactory();
RelDataType rowType = TypeUtils.createRowType(tf, int.class, int.class);
ScanNode<Object[]> scan = new ScanNode<>(ctx, rowType, new TestTable(grps * rowsInGroup, rowType, (r) -> r / rowsInGroup, (r) -> r % rowsInGroup));
AggregateCall call = AggregateCall.create(SqlStdOperatorTable.SUM, false, false, false, ImmutableIntList.of(1), -1, RelCollations.EMPTY, tf.createJavaType(int.class), null);
List<ImmutableBitSet> grpSets = List.of(ImmutableBitSet.of(0));
RelDataType aggRowType = TypeUtils.createRowType(tf, int.class);
SingleNode<Object[]> aggChain = createAggregateNodesChain(testAgg, ctx, grpSets, call, rowType, aggRowType, rowFactory(), scan);
RootNode<Object[]> root = new RootNode<>(ctx, aggRowType);
root.register(aggChain);
IntSet grpId = new IntOpenHashSet(IntStream.range(0, grps).toArray());
while (root.hasNext()) {
Object[] row = root.next();
grpId.remove(((Integer) row[0]).intValue());
assertEquals((rowsInGroup - 1) * rowsInGroup / 2, row[1]);
}
assertTrue(grpId.isEmpty());
}
}
}
Aggregations