Search in sources :

Example 1 with CatalogSchemaTable

use of org.apache.flink.table.planner.catalog.CatalogSchemaTable in project flink by apache.

the class FlinkCalciteCatalogReaderTest method testGetFlinkPreparingTableBase.

@Test
public void testGetFlinkPreparingTableBase() {
    // Mock CatalogSchemaTable.
    final ObjectIdentifier objectIdentifier = ObjectIdentifier.of("a", "b", "c");
    final ResolvedSchema schema = new ResolvedSchema(Collections.emptyList(), Collections.emptyList(), null);
    final CatalogTable catalogTable = ConnectorCatalogTable.source(new TestTableSource(true, TableSchema.fromResolvedSchema(schema)), true);
    final ResolvedCatalogTable resolvedCatalogTable = new ResolvedCatalogTable(catalogTable, schema);
    CatalogSchemaTable mockTable = new CatalogSchemaTable(ContextResolvedTable.permanent(objectIdentifier, CatalogManagerMocks.createEmptyCatalog(), resolvedCatalogTable), FlinkStatistic.UNKNOWN(), true);
    rootSchemaPlus.add(tableMockName, mockTable);
    Prepare.PreparingTable preparingTable = catalogReader.getTable(Collections.singletonList(tableMockName));
    assertTrue(preparingTable instanceof FlinkPreparingTableBase);
}
Also used : TestTableSource(org.apache.flink.table.planner.utils.TestTableSource) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) CatalogSchemaTable(org.apache.flink.table.planner.catalog.CatalogSchemaTable) Prepare(org.apache.calcite.prepare.Prepare) FlinkPreparingTableBase(org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase) ConnectorCatalogTable(org.apache.flink.table.catalog.ConnectorCatalogTable) CatalogTable(org.apache.flink.table.catalog.CatalogTable) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) ResolvedSchema(org.apache.flink.table.catalog.ResolvedSchema) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier) Test(org.junit.Test)

Example 2 with CatalogSchemaTable

use of org.apache.flink.table.planner.catalog.CatalogSchemaTable in project flink by apache.

the class CatalogSourceTable method createAnonymous.

/**
 * Create a {@link CatalogSourceTable} from an anonymous {@link ContextResolvedTable}. This is
 * required to manually create a preparing table skipping the calcite catalog resolution.
 */
public static CatalogSourceTable createAnonymous(FlinkRelBuilder relBuilder, ContextResolvedTable contextResolvedTable, boolean isBatchMode) {
    Preconditions.checkArgument(contextResolvedTable.isAnonymous(), "ContextResolvedTable must be anonymous");
    // Statistics are unknown for anonymous tables
    // Look at DatabaseCalciteSchema#getStatistic for more details
    FlinkStatistic flinkStatistic = FlinkStatistic.unknown(contextResolvedTable.getResolvedSchema()).build();
    CatalogSchemaTable catalogSchemaTable = new CatalogSchemaTable(contextResolvedTable, flinkStatistic, !isBatchMode);
    return new CatalogSourceTable(relBuilder.getRelOptSchema(), contextResolvedTable.getIdentifier().toList(), catalogSchemaTable.getRowType(relBuilder.getTypeFactory()), catalogSchemaTable);
}
Also used : FlinkStatistic(org.apache.flink.table.planner.plan.stats.FlinkStatistic) CatalogSchemaTable(org.apache.flink.table.planner.catalog.CatalogSchemaTable)

Aggregations

CatalogSchemaTable (org.apache.flink.table.planner.catalog.CatalogSchemaTable)2 Prepare (org.apache.calcite.prepare.Prepare)1 CatalogTable (org.apache.flink.table.catalog.CatalogTable)1 ConnectorCatalogTable (org.apache.flink.table.catalog.ConnectorCatalogTable)1 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)1 ResolvedCatalogTable (org.apache.flink.table.catalog.ResolvedCatalogTable)1 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)1 FlinkPreparingTableBase (org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase)1 FlinkStatistic (org.apache.flink.table.planner.plan.stats.FlinkStatistic)1 TestTableSource (org.apache.flink.table.planner.utils.TestTableSource)1 Test (org.junit.Test)1