Search in sources :

Example 1 with FlinkCalciteCatalogReader

use of org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader in project flink by apache.

the class PlannerContext method createCatalogReader.

public FlinkCalciteCatalogReader createCatalogReader(boolean lenientCaseSensitivity, String currentCatalog, String currentDatabase) {
    SqlParser.Config sqlParserConfig = getSqlParserConfig();
    final boolean caseSensitive;
    if (lenientCaseSensitivity) {
        caseSensitive = false;
    } else {
        caseSensitive = sqlParserConfig.caseSensitive();
    }
    SqlParser.Config newSqlParserConfig = SqlParser.configBuilder(sqlParserConfig).setCaseSensitive(caseSensitive).build();
    SchemaPlus rootSchema = getRootSchema(this.rootSchema.plus());
    return new FlinkCalciteCatalogReader(CalciteSchema.from(rootSchema), asList(asList(currentCatalog, currentDatabase), singletonList(currentCatalog)), typeFactory, CalciteConfig$.MODULE$.connectionConfig(newSqlParserConfig));
}
Also used : SqlParser(org.apache.calcite.sql.parser.SqlParser) SchemaPlus(org.apache.calcite.schema.SchemaPlus) FlinkCalciteCatalogReader(org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader)

Example 2 with FlinkCalciteCatalogReader

use of org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader in project flink by apache.

the class PlannerContext method createRelBuilder.

/**
 * Creates a configured {@link FlinkRelBuilder} for a planning session.
 *
 * @param currentCatalog the current default catalog to look for first during planning.
 * @param currentDatabase the current default database to look for first during planning.
 * @return configured rel builder
 */
public FlinkRelBuilder createRelBuilder(String currentCatalog, String currentDatabase) {
    FlinkCalciteCatalogReader relOptSchema = createCatalogReader(false, currentCatalog, currentDatabase);
    Context chain = Contexts.of(context, // Sets up the ViewExpander explicitly for FlinkRelBuilder.
    createFlinkPlanner(currentCatalog, currentDatabase).createToRelContext());
    return new FlinkRelBuilder(chain, cluster, relOptSchema);
}
Also used : Context(org.apache.calcite.plan.Context) FlinkContext(org.apache.flink.table.planner.calcite.FlinkContext) FlinkRelBuilder(org.apache.flink.table.planner.calcite.FlinkRelBuilder) FlinkCalciteCatalogReader(org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader)

Aggregations

FlinkCalciteCatalogReader (org.apache.flink.table.planner.plan.FlinkCalciteCatalogReader)2 Context (org.apache.calcite.plan.Context)1 SchemaPlus (org.apache.calcite.schema.SchemaPlus)1 SqlParser (org.apache.calcite.sql.parser.SqlParser)1 FlinkContext (org.apache.flink.table.planner.calcite.FlinkContext)1 FlinkRelBuilder (org.apache.flink.table.planner.calcite.FlinkRelBuilder)1