Search in sources :

Example 1 with SidewinderDatabaseSchema

use of com.srotya.sidewinder.core.sql.calcite.SidewinderDatabaseSchema in project sidewinder by srotya.

the class SqlApi method checkAndAddSchema.

public boolean checkAndAddSchema(String dbName) throws Exception {
    synchronized (connection) {
        if (!engine.checkIfExists(dbName)) {
            return false;
        }
        CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
        String tdbName = dbName.toUpperCase();
        if (calciteConnection.getRootSchema().getSubSchema(tdbName) == null) {
            System.err.println("Adding DB to connection:" + dbName + "\t" + tdbName);
            calciteConnection.getRootSchema().add(tdbName, new SidewinderDatabaseSchema(engine, dbName));
        }
        return true;
    }
}
Also used : SidewinderDatabaseSchema(com.srotya.sidewinder.core.sql.calcite.SidewinderDatabaseSchema) CalciteConnection(org.apache.calcite.jdbc.CalciteConnection)

Aggregations

SidewinderDatabaseSchema (com.srotya.sidewinder.core.sql.calcite.SidewinderDatabaseSchema)1 CalciteConnection (org.apache.calcite.jdbc.CalciteConnection)1