use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus in project calcite by apache.
the class PlannerImpl method ready.
private void ready() {
switch(state) {
case STATE_0_CLOSED:
reset();
}
ensure(State.STATE_1_RESET);
Frameworks.withPlanner(new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema, SchemaPlus rootSchema) {
// use our own defaultSchema
Util.discard(rootSchema);
typeFactory = (JavaTypeFactory) cluster.getTypeFactory();
planner = cluster.getPlanner();
planner.setExecutor(executor);
return null;
}
}, config);
state = State.STATE_2_READY;
// then, register the trait def specified in traitDefs.
if (this.traitDefs != null) {
planner.clearRelTraitDefs();
for (RelTraitDef def : this.traitDefs) {
planner.addRelTraitDef(def);
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus in project calcite by apache.
the class RelMetadataTest method testAllPredicates.
@Test
public void testAllPredicates() {
final Project rel = (Project) convertSql("select * from emp, dept");
final Join join = (Join) rel.getInput();
final RelOptTable empTable = join.getInput(0).getTable();
final RelOptTable deptTable = join.getInput(1).getTable();
Frameworks.withPlanner(new Frameworks.PlannerAction<Void>() {
public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema, SchemaPlus rootSchema) {
checkAllPredicates(cluster, empTable, deptTable);
return null;
}
});
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus in project calcite by apache.
the class TableFunctionTest method testTableFunction.
/**
* Tests a table function with literal arguments.
*/
@Test
public void testTableFunction() throws SQLException, ClassNotFoundException {
Connection connection = DriverManager.getConnection("jdbc:calcite:");
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
final TableFunction table = TableFunctionImpl.create(Smalls.GENERATE_STRINGS_METHOD);
schema.add("GenerateStrings", table);
ResultSet resultSet = connection.createStatement().executeQuery("select *\n" + "from table(\"s\".\"GenerateStrings\"(5)) as t(n, c)\n" + "where char_length(c) > 3");
assertThat(CalciteAssert.toString(resultSet), equalTo("N=4; C=abcd\n"));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus in project calcite by apache.
the class TableFunctionTest method getConnectionWithMultiplyFunction.
private Connection getConnectionWithMultiplyFunction() throws ClassNotFoundException, SQLException {
Connection connection = DriverManager.getConnection("jdbc:calcite:");
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
final TableFunction table = TableFunctionImpl.create(Smalls.MULTIPLICATION_TABLE_METHOD);
schema.add("multiplication", table);
return connection;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus in project calcite by apache.
the class TableFunctionTest method testScannableTableFunction.
/**
* Tests a table function that implements {@link ScannableTable} and returns
* a single column.
*/
@Test
public void testScannableTableFunction() throws SQLException, ClassNotFoundException {
Connection connection = DriverManager.getConnection("jdbc:calcite:");
CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
SchemaPlus schema = rootSchema.add("s", new AbstractSchema());
final TableFunction table = TableFunctionImpl.create(Smalls.MAZE_METHOD);
schema.add("Maze", table);
final String sql = "select *\n" + "from table(\"s\".\"Maze\"(5, 3, 1))";
ResultSet resultSet = connection.createStatement().executeQuery(sql);
final String result = "S=abcde\n" + "S=xyz\n" + "S=generate(w=5, h=3, s=1)\n";
assertThat(CalciteAssert.toString(resultSet), is(result));
}
Aggregations