use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretUnionAll.
/**
* Tests executing a UNION ALL query using an interpreter.
*/
@Test
public void testInterpretUnionAll() throws Exception {
rootSchema.add("simple", new ScannableTableTest.SimpleTable());
SqlNode parse = planner.parse("select * from \"simple\"\n" + "union all\n" + "select * from \"simple\"\n");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[0]", "[10]", "[20]", "[30]", "[0]", "[10]", "[20]", "[30]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testAggregateGroup.
@Test
public void testAggregateGroup() throws Exception {
rootSchema.add("beatles", new ScannableTableTest.BeatlesTable());
SqlNode parse = planner.parse("select \"j\", count(*) from \"beatles\" group by \"j\"");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRowsUnordered(interpreter, "[George, 1]", "[Paul, 1]", "[John, 1]", "[Ringo, 1]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testAggregate.
@Test
public void testAggregate() throws Exception {
rootSchema.add("beatles", new ScannableTableTest.BeatlesTable());
SqlNode parse = planner.parse("select count(*) from \"beatles\"");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[4]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class EnumerableInterpreter method implement.
public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final JavaTypeFactory typeFactory = implementor.getTypeFactory();
final BlockBuilder builder = new BlockBuilder();
final PhysType physType = PhysTypeImpl.of(typeFactory, getRowType(), JavaRowFormat.ARRAY);
final Expression interpreter_ = builder.append("interpreter", Expressions.new_(Interpreter.class, implementor.getRootExpression(), implementor.stash(getInput(), RelNode.class)));
final Expression sliced_ = getRowType().getFieldCount() == 1 ? Expressions.call(BuiltInMethod.SLICE0.method, interpreter_) : interpreter_;
builder.add(sliced_);
return implementor.result(physType, builder.toBlock());
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretUnion.
/**
* Tests executing a UNION query using an interpreter.
*/
@Test
public void testInterpretUnion() throws Exception {
rootSchema.add("simple", new ScannableTableTest.SimpleTable());
SqlNode parse = planner.parse("select * from \"simple\"\n" + "union\n" + "select * from \"simple\"\n");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[0]", "[10]", "[20]", "[30]");
}
Aggregations