Search in sources :

Example 1 with ConnectionPostProcessor

use of org.apache.calcite.test.CalciteAssert.ConnectionPostProcessor in project calcite by apache.

the class ScannableTableTest method newSchema.

protected ConnectionPostProcessor newSchema(final String schemaName, final String tableName, final Table table) {
    return new ConnectionPostProcessor() {

        @Override
        public Connection apply(Connection connection) throws SQLException {
            CalciteConnection con = connection.unwrap(CalciteConnection.class);
            SchemaPlus rootSchema = con.getRootSchema();
            SchemaPlus schema = rootSchema.add(schemaName, new AbstractSchema());
            schema.add(tableName, table);
            connection.setSchema(schemaName);
            return connection;
        }
    };
}
Also used : ConnectionPostProcessor(org.apache.calcite.test.CalciteAssert.ConnectionPostProcessor) AbstractSchema(org.apache.calcite.schema.impl.AbstractSchema) Connection(java.sql.Connection) CalciteConnection(org.apache.calcite.jdbc.CalciteConnection) SchemaPlus(org.apache.calcite.schema.SchemaPlus) CalciteConnection(org.apache.calcite.jdbc.CalciteConnection)

Aggregations

Connection (java.sql.Connection)1 CalciteConnection (org.apache.calcite.jdbc.CalciteConnection)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 AbstractSchema (org.apache.calcite.schema.impl.AbstractSchema)1 ConnectionPostProcessor (org.apache.calcite.test.CalciteAssert.ConnectionPostProcessor)1