Search in sources :

Example 1 with Prepare

use of org.apache.calcite.prepare.Prepare in project druid by druid-io.

the class DruidPlanner method getValidator.

/**
 * Constructs an SQL validator, just like papa {@link #planner} uses.
 */
private SqlValidator getValidator() {
    // this is sort of lame, planner won't cough up its validator, which is nice and seeded after validating a query,
    // but it is private and has no accessors, so make another one so we can get the parameter types... but i suppose
    // beats creating our own Prepare and Planner implementations
    Preconditions.checkNotNull(planner.getTypeFactory());
    final CalciteConnectionConfig connectionConfig;
    if (frameworkConfig.getContext() != null) {
        connectionConfig = frameworkConfig.getContext().unwrap(CalciteConnectionConfig.class);
    } else {
        Properties properties = new Properties();
        properties.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), String.valueOf(PlannerFactory.PARSER_CONFIG.caseSensitive()));
        connectionConfig = new CalciteConnectionConfigImpl(properties);
    }
    Prepare.CatalogReader catalogReader = new CalciteCatalogReader(CalciteSchema.from(frameworkConfig.getDefaultSchema().getParentSchema()), CalciteSchema.from(frameworkConfig.getDefaultSchema()).path(null), planner.getTypeFactory(), connectionConfig);
    return SqlValidatorUtil.newValidator(frameworkConfig.getOperatorTable(), catalogReader, planner.getTypeFactory(), DruidConformance.instance());
}
Also used : CalciteConnectionConfigImpl(org.apache.calcite.config.CalciteConnectionConfigImpl) CalciteCatalogReader(org.apache.calcite.prepare.CalciteCatalogReader) CalciteConnectionConfig(org.apache.calcite.config.CalciteConnectionConfig) Prepare(org.apache.calcite.prepare.Prepare) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)1 CalciteConnectionConfig (org.apache.calcite.config.CalciteConnectionConfig)1 CalciteConnectionConfigImpl (org.apache.calcite.config.CalciteConnectionConfigImpl)1 CalciteCatalogReader (org.apache.calcite.prepare.CalciteCatalogReader)1 Prepare (org.apache.calcite.prepare.Prepare)1