use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testAggregateGroupFilter.
@Test
public void testAggregateGroupFilter() throws Exception {
rootSchema.add("beatles", new ScannableTableTest.BeatlesTable());
final String sql = "select \"j\",\n" + " count(*) filter (where char_length(\"j\") > 4)\n" + "from \"beatles\" group by \"j\"";
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRowsUnordered(interpreter, "[George, 1]", "[Paul, 0]", "[John, 0]", "[Ringo, 1]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretOrder.
/**
* Tests a plan where the sort field is projected away.
*/
@Test
public void testInterpretOrder() throws Exception {
final String sql = "select y\n" + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n" + "order by -x";
SqlNode parse = planner.parse(sql);
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).project();
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[c]", "[b]", "[a]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretTable.
/**
* Tests executing a simple plan using an interpreter.
*/
@Test
public void testInterpretTable() throws Exception {
SqlNode parse = planner.parse("select * from \"hr\".\"emps\" order by \"empid\"");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[100, 10, Bill, 10000.0, 1000]", "[110, 10, Theodore, 11500.0, 250]", "[150, 10, Sebastian, 7000.0, null]", "[200, 20, Eric, 8000.0, 500]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretScannableTable.
/**
* Tests executing a plan on a
* {@link org.apache.calcite.schema.ScannableTable} using an interpreter.
*/
@Test
public void testInterpretScannableTable() throws Exception {
rootSchema.add("beatles", new ScannableTableTest.BeatlesTable());
SqlNode parse = planner.parse("select * from \"beatles\" order by \"i\"");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[4, John]", "[4, Paul]", "[5, Ringo]", "[6, George]");
}
use of org.apache.calcite.interpreter.Interpreter in project calcite by apache.
the class InterpreterTest method testInterpretSimpleScannableTable.
/**
* Tests executing a plan on a single-column
* {@link org.apache.calcite.schema.ScannableTable} using an interpreter.
*/
@Test
public void testInterpretSimpleScannableTable() throws Exception {
rootSchema.add("simple", new ScannableTableTest.SimpleTable());
SqlNode parse = planner.parse("select * from \"simple\" limit 2");
SqlNode validate = planner.validate(parse);
RelNode convert = planner.rel(validate).rel;
final Interpreter interpreter = new Interpreter(dataContext, convert);
assertRows(interpreter, "[0]", "[10]");
}
Aggregations