Search in sources :

Example 1 with ExternalModifyOperation

use of org.apache.flink.table.operations.ExternalModifyOperation in project flink by apache.

the class AbstractStreamTableEnvironmentImpl method toStreamInternal.

protected <T> DataStream<T> toStreamInternal(Table table, SchemaTranslator.ProducingResult schemaTranslationResult, @Nullable ChangelogMode changelogMode) {
    final CatalogManager catalogManager = getCatalogManager();
    final OperationTreeBuilder operationTreeBuilder = getOperationTreeBuilder();
    final QueryOperation projectOperation = schemaTranslationResult.getProjections().map(projections -> operationTreeBuilder.project(projections.stream().map(ApiExpressionUtils::unresolvedRef).collect(Collectors.toList()), table.getQueryOperation())).orElseGet(table::getQueryOperation);
    final ResolvedCatalogTable resolvedCatalogTable = catalogManager.resolveCatalogTable(new ExternalCatalogTable(schemaTranslationResult.getSchema()));
    final ExternalModifyOperation modifyOperation = new ExternalModifyOperation(ContextResolvedTable.anonymous("datastream_sink", resolvedCatalogTable), projectOperation, changelogMode, schemaTranslationResult.getPhysicalDataType().orElseGet(() -> resolvedCatalogTable.getResolvedSchema().toPhysicalRowDataType()));
    return toStreamInternal(table, modifyOperation);
}
Also used : DataType(org.apache.flink.table.types.DataType) CatalogManager(org.apache.flink.table.catalog.CatalogManager) ModifyOperation(org.apache.flink.table.operations.ModifyOperation) QueryOperation(org.apache.flink.table.operations.QueryOperation) Schema(org.apache.flink.table.api.Schema) ObjectIdentifier(org.apache.flink.table.catalog.ObjectIdentifier) DataStreamQueryOperation(org.apache.flink.table.operations.DataStreamQueryOperation) Tuple2(org.apache.flink.api.java.tuple.Tuple2) UnresolvedIdentifier(org.apache.flink.table.catalog.UnresolvedIdentifier) ChangelogMode(org.apache.flink.table.connector.ChangelogMode) ExecutorFactory(org.apache.flink.table.delegation.ExecutorFactory) TupleTypeInfo(org.apache.flink.api.java.typeutils.TupleTypeInfo) Types(org.apache.flink.table.api.Types) FunctionCatalog(org.apache.flink.table.catalog.FunctionCatalog) Planner(org.apache.flink.table.delegation.Planner) ExternalQueryOperation(org.apache.flink.table.operations.ExternalQueryOperation) Expression(org.apache.flink.table.expressions.Expression) TableEnvironmentImpl(org.apache.flink.table.api.internal.TableEnvironmentImpl) OperationTreeBuilder(org.apache.flink.table.operations.utils.OperationTreeBuilder) TypeInformation(org.apache.flink.api.common.typeinfo.TypeInformation) ExternalModifyOperation(org.apache.flink.table.operations.ExternalModifyOperation) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) Nullable(javax.annotation.Nullable) ContextResolvedTable(org.apache.flink.table.catalog.ContextResolvedTable) TimeCharacteristic(org.apache.flink.streaming.api.TimeCharacteristic) SchemaTranslator(org.apache.flink.table.catalog.SchemaTranslator) ModuleManager(org.apache.flink.table.module.ModuleManager) TableConfig(org.apache.flink.table.api.TableConfig) TableException(org.apache.flink.table.api.TableException) Table(org.apache.flink.table.api.Table) StreamExecutorFactory(org.apache.flink.table.delegation.StreamExecutorFactory) Preconditions(org.apache.flink.util.Preconditions) Collectors(java.util.stream.Collectors) FieldInfoUtils(org.apache.flink.table.typeutils.FieldInfoUtils) DataStream(org.apache.flink.streaming.api.datastream.DataStream) ExternalCatalogTable(org.apache.flink.table.catalog.ExternalCatalogTable) List(java.util.List) TypeExtractor(org.apache.flink.api.java.typeutils.TypeExtractor) FactoryUtil(org.apache.flink.table.factories.FactoryUtil) ValidationException(org.apache.flink.table.api.ValidationException) Executor(org.apache.flink.table.delegation.Executor) ApiExpressionUtils(org.apache.flink.table.expressions.ApiExpressionUtils) Optional(java.util.Optional) Internal(org.apache.flink.annotation.Internal) TypeConversions(org.apache.flink.table.types.utils.TypeConversions) Transformation(org.apache.flink.api.dag.Transformation) Collections(java.util.Collections) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) ExternalModifyOperation(org.apache.flink.table.operations.ExternalModifyOperation) ResolvedCatalogTable(org.apache.flink.table.catalog.ResolvedCatalogTable) ExternalCatalogTable(org.apache.flink.table.catalog.ExternalCatalogTable) OperationTreeBuilder(org.apache.flink.table.operations.utils.OperationTreeBuilder) ApiExpressionUtils(org.apache.flink.table.expressions.ApiExpressionUtils) CatalogManager(org.apache.flink.table.catalog.CatalogManager) QueryOperation(org.apache.flink.table.operations.QueryOperation) DataStreamQueryOperation(org.apache.flink.table.operations.DataStreamQueryOperation) ExternalQueryOperation(org.apache.flink.table.operations.ExternalQueryOperation)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Internal (org.apache.flink.annotation.Internal)1 TypeInformation (org.apache.flink.api.common.typeinfo.TypeInformation)1 Transformation (org.apache.flink.api.dag.Transformation)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 TupleTypeInfo (org.apache.flink.api.java.typeutils.TupleTypeInfo)1 TypeExtractor (org.apache.flink.api.java.typeutils.TypeExtractor)1 TimeCharacteristic (org.apache.flink.streaming.api.TimeCharacteristic)1 DataStream (org.apache.flink.streaming.api.datastream.DataStream)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 Schema (org.apache.flink.table.api.Schema)1 Table (org.apache.flink.table.api.Table)1 TableConfig (org.apache.flink.table.api.TableConfig)1 TableException (org.apache.flink.table.api.TableException)1 Types (org.apache.flink.table.api.Types)1 ValidationException (org.apache.flink.table.api.ValidationException)1