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);
}
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);
}
Aggregations