Search in sources :

Example 16 with CalciteConnectionConfig

use of org.apache.calcite.config.CalciteConnectionConfig 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

CalciteConnectionConfig (org.apache.calcite.config.CalciteConnectionConfig)14 RelDataType (org.apache.calcite.rel.type.RelDataType)5 SqlNode (org.apache.calcite.sql.SqlNode)5 Properties (java.util.Properties)4 DataContext (org.apache.calcite.DataContext)4 CalciteConnectionConfigImpl (org.apache.calcite.config.CalciteConnectionConfigImpl)4 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)4 ScannableTable (org.apache.calcite.schema.ScannableTable)4 Schema (org.apache.calcite.schema.Schema)4 SqlCall (org.apache.calcite.sql.SqlCall)4 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CalciteConnectionConfig (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.config.CalciteConnectionConfig)2 RelTraitDef (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitDef)2 CalciteCatalogReader (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.prepare.CalciteCatalogReader)2 SchemaPlus (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.schema.SchemaPlus)2 SqlOperatorTable (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlOperatorTable)2 SqlParser (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParser)2 SqlParserImplFactory (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.parser.SqlParserImplFactory)2