Search in sources :

Example 1 with QueryOperationCatalogView

use of org.apache.flink.table.catalog.QueryOperationCatalogView in project flink by apache.

the class FlinkCalciteCatalogReader method toPreparingTable.

/**
 * Translate this {@link CatalogSchemaTable} into Flink source table.
 */
private static FlinkPreparingTableBase toPreparingTable(RelOptSchema relOptSchema, List<String> names, RelDataType rowType, CatalogSchemaTable schemaTable) {
    final ResolvedCatalogBaseTable<?> resolvedBaseTable = schemaTable.getContextResolvedTable().getResolvedTable();
    final CatalogBaseTable originTable = resolvedBaseTable.getOrigin();
    if (originTable instanceof QueryOperationCatalogView) {
        return convertQueryOperationView(relOptSchema, names, rowType, (QueryOperationCatalogView) originTable);
    } else if (originTable instanceof ConnectorCatalogTable) {
        ConnectorCatalogTable<?, ?> connectorTable = (ConnectorCatalogTable<?, ?>) originTable;
        if ((connectorTable).getTableSource().isPresent()) {
            return convertLegacyTableSource(relOptSchema, rowType, schemaTable.getContextResolvedTable().getIdentifier(), connectorTable, schemaTable.getStatistic(), schemaTable.isStreamingMode());
        } else {
            throw new ValidationException("Cannot convert a connector table " + "without source.");
        }
    } else if (originTable instanceof CatalogView) {
        return convertCatalogView(relOptSchema, names, rowType, schemaTable.getStatistic(), (CatalogView) originTable);
    } else if (originTable instanceof CatalogTable) {
        return convertCatalogTable(relOptSchema, names, rowType, schemaTable);
    } else {
        throw new ValidationException("Unsupported table type: " + originTable);
    }
}
Also used : CatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable) ResolvedCatalogBaseTable(org.apache.flink.table.catalog.ResolvedCatalogBaseTable) ValidationException(org.apache.flink.table.api.ValidationException) ConnectorCatalogTable(org.apache.flink.table.catalog.ConnectorCatalogTable) QueryOperationCatalogView(org.apache.flink.table.catalog.QueryOperationCatalogView) ConnectorCatalogTable(org.apache.flink.table.catalog.ConnectorCatalogTable) CatalogTable(org.apache.flink.table.catalog.CatalogTable) CatalogView(org.apache.flink.table.catalog.CatalogView) QueryOperationCatalogView(org.apache.flink.table.catalog.QueryOperationCatalogView)

Example 2 with QueryOperationCatalogView

use of org.apache.flink.table.catalog.QueryOperationCatalogView in project flink by apache.

the class TableEnvironmentImpl method createTemporaryView.

private void createTemporaryView(UnresolvedIdentifier identifier, Table view) {
    if (((TableImpl) view).getTableEnvironment() != this) {
        throw new TableException("Only table API objects that belong to this TableEnvironment can be registered.");
    }
    ObjectIdentifier tableIdentifier = catalogManager.qualifyIdentifier(identifier);
    QueryOperation queryOperation = qualifyQueryOperation(tableIdentifier, view.getQueryOperation());
    CatalogBaseTable tableTable = new QueryOperationCatalogView(queryOperation);
    catalogManager.createTemporaryTable(tableTable, tableIdentifier, false);
}
Also used : TableException(org.apache.flink.table.api.TableException) CatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable) QueryOperationCatalogView(org.apache.flink.table.catalog.QueryOperationCatalogView) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier) QueryOperation(org.apache.flink.table.operations.QueryOperation) TableSourceQueryOperation(org.apache.flink.table.operations.TableSourceQueryOperation) SourceQueryOperation(org.apache.flink.table.operations.SourceQueryOperation)

Aggregations

CatalogBaseTable (org.apache.flink.table.catalog.CatalogBaseTable)2 QueryOperationCatalogView (org.apache.flink.table.catalog.QueryOperationCatalogView)2 TableException (org.apache.flink.table.api.TableException)1 ValidationException (org.apache.flink.table.api.ValidationException)1 CatalogTable (org.apache.flink.table.catalog.CatalogTable)1 CatalogView (org.apache.flink.table.catalog.CatalogView)1 ConnectorCatalogTable (org.apache.flink.table.catalog.ConnectorCatalogTable)1 ObjectIdentifier (org.apache.flink.table.catalog.ObjectIdentifier)1 ResolvedCatalogBaseTable (org.apache.flink.table.catalog.ResolvedCatalogBaseTable)1 QueryOperation (org.apache.flink.table.operations.QueryOperation)1 SourceQueryOperation (org.apache.flink.table.operations.SourceQueryOperation)1 TableSourceQueryOperation (org.apache.flink.table.operations.TableSourceQueryOperation)1