use of org.apache.calcite.prepare.CalcitePrepareImpl in project calcite by apache.
the class Frameworks method withPrepare.
/**
* Initializes a container then calls user-specified code with a planner
* and statement.
*
* @param action Callback containing user-specified code
* @return Return value from action
*/
public static <R> R withPrepare(PrepareAction<R> action) {
try {
final Properties info = new Properties();
if (action.config.getTypeSystem() != RelDataTypeSystem.DEFAULT) {
info.setProperty(CalciteConnectionProperty.TYPE_SYSTEM.camelName(), action.config.getTypeSystem().getClass().getName());
}
Connection connection = DriverManager.getConnection("jdbc:calcite:", info);
final CalciteServerStatement statement = connection.createStatement().unwrap(CalciteServerStatement.class);
return new CalcitePrepareImpl().perform(statement, action);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations