Search in sources :

Example 1 with FlinkPreparingTableBase

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

the class FlinkCalciteCatalogReaderTest method testGetNonFlinkPreparingTableBase.

@Test
public void testGetNonFlinkPreparingTableBase() {
    Table nonFlinkTableMock = mock(Table.class);
    when(nonFlinkTableMock.getRowType(typeFactory)).thenReturn(mock(RelDataType.class));
    rootSchemaPlus.add(tableMockName, nonFlinkTableMock);
    Prepare.PreparingTable resultTable = catalogReader.getTable(Collections.singletonList(tableMockName));
    assertFalse(resultTable instanceof FlinkPreparingTableBase);
}
Also used : ConnectorCatalogTable(org.apache.flink.table.catalog.ConnectorCatalogTable) CatalogSchemaTable(org.apache.flink.table.planner.catalog.CatalogSchemaTable) CatalogTable(org.apache.flink.table.catalog.CatalogTable) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) ContextResolvedTable(org.apache.flink.table.catalog.ContextResolvedTable) Table(org.apache.calcite.schema.Table) Prepare(org.apache.calcite.prepare.Prepare) FlinkPreparingTableBase(org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase) RelDataType(org.apache.calcite.rel.type.RelDataType) Test(org.junit.Test)

Example 2 with FlinkPreparingTableBase

use of org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase 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)

Aggregations

Prepare (org.apache.calcite.prepare.Prepare)2 CatalogTable (org.apache.flink.table.catalog.CatalogTable)2 ConnectorCatalogTable (org.apache.flink.table.catalog.ConnectorCatalogTable)2 ResolvedCatalogTable (org.apache.flink.table.catalog.ResolvedCatalogTable)2 CatalogSchemaTable (org.apache.flink.table.planner.catalog.CatalogSchemaTable)2 FlinkPreparingTableBase (org.apache.flink.table.planner.plan.schema.FlinkPreparingTableBase)2 Test (org.junit.Test)2 RelDataType (org.apache.calcite.rel.type.RelDataType)1 Table (org.apache.calcite.schema.Table)1 ContextResolvedTable (org.apache.flink.table.catalog.ContextResolvedTable)1 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)1 ResolvedSchema (org.apache.flink.table.catalog.ResolvedSchema)1 TestTableSource (org.apache.flink.table.planner.utils.TestTableSource)1