use of org.apache.flink.table.types.logical.utils.LogicalTypeMerging in project flink by apache.
the class ValuesOperationFactory method create.
/**
* Creates a valid {@link ValuesQueryOperation} operation.
*
* <p>It derives a row type based on {@link LogicalTypeMerging}. It flattens any row
* constructors. It does not flatten ROWs which are a result of e.g. a function call.
*
* <p>The resulting schema can be provided manually. If it is not, the schema will be
* automatically derived from the types of the expressions.
*/
QueryOperation create(@Nullable ResolvedSchema expectedSchema, List<ResolvedExpression> resolvedExpressions, ExpressionResolver.PostResolverFactory postResolverFactory) {
List<List<ResolvedExpression>> resolvedRows = unwrapFromRowConstructor(resolvedExpressions);
if (expectedSchema != null) {
verifyAllSameSize(resolvedRows, expectedSchema.getColumnCount());
}
ResolvedSchema schema = Optional.ofNullable(expectedSchema).orElseGet(() -> extractSchema(resolvedRows));
List<List<ResolvedExpression>> castedExpressions = resolvedRows.stream().map(row -> convertTopLevelExpressionToExpectedRowType(postResolverFactory, schema.getColumnDataTypes(), row)).collect(Collectors.toList());
return new ValuesQueryOperation(castedExpressions, schema);
}
Aggregations