use of org.apache.ignite.internal.sql.engine.exec.ExecutionContext in project ignite-3 by apache.
the class AbstractSetOpExecutionTest method checkSetOp.
/**
* CheckSetOp.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*
* @param single Single.
* @param all All.
*/
protected void checkSetOp(boolean single, boolean all, List<List<Object[]>> dataSets, List<Object[]> expectedResult) {
ExecutionContext<Object[]> ctx = executionContext();
IgniteTypeFactory tf = ctx.getTypeFactory();
RelDataType rowType = TypeUtils.createRowType(tf, String.class, int.class);
List<Node<Object[]>> inputs = dataSets.stream().map(ds -> new ScanNode<>(ctx, rowType, ds)).collect(Collectors.toList());
AbstractSetOpNode<Object[]> setOpNode;
if (single) {
setOpNode = setOpNodeFactory(ctx, rowType, SINGLE, all, inputs.size());
} else {
setOpNode = setOpNodeFactory(ctx, rowType, MAP, all, inputs.size());
}
setOpNode.register(inputs);
if (!single) {
AbstractSetOpNode<Object[]> reduceNode = setOpNodeFactory(ctx, rowType, REDUCE, all, 1);
reduceNode.register(Collections.singletonList(setOpNode));
setOpNode = reduceNode;
}
Comparator<Object[]> cmp = ctx.expressionFactory().comparator(RelCollations.of(ImmutableIntList.of(0, 1)));
// Create sort node on the top to check sorted results.
SortNode<Object[]> sortNode = new SortNode<>(ctx, rowType, cmp);
sortNode.register(setOpNode);
RootNode<Object[]> root = new RootNode<>(ctx, rowType);
root.register(sortNode);
assertTrue(nullOrEmpty(expectedResult) || root.hasNext());
for (Object[] row : expectedResult) {
assertArrayEquals(row, root.next());
}
assertFalse(root.hasNext());
}
Aggregations