use of org.apache.flink.table.planner.expressions.converter.ExpressionConverter in project flink by apache.
the class DynamicSourceUtils method pushGeneratedProjection.
/**
* Creates a projection that adds computed columns and finalizes the table schema.
*/
private static void pushGeneratedProjection(FlinkRelBuilder relBuilder, ResolvedSchema schema) {
final ExpressionConverter converter = new ExpressionConverter(relBuilder);
final List<RexNode> projection = schema.getColumns().stream().map(c -> {
if (c instanceof ComputedColumn) {
final ComputedColumn computedColumn = (ComputedColumn) c;
return computedColumn.getExpression().accept(converter);
} else {
return relBuilder.field(c.getName());
}
}).collect(Collectors.toList());
relBuilder.projectNamed(projection, schema.getColumns().stream().map(Column::getName).collect(Collectors.toList()), true);
}
use of org.apache.flink.table.planner.expressions.converter.ExpressionConverter in project flink by apache.
the class DynamicSourceUtils method pushWatermarkAssigner.
// --------------------------------------------------------------------------------------------
/**
* Creates a specialized node for assigning watermarks.
*/
private static void pushWatermarkAssigner(FlinkRelBuilder relBuilder, ResolvedSchema schema) {
final ExpressionConverter converter = new ExpressionConverter(relBuilder);
final RelDataType inputRelDataType = relBuilder.peek().getRowType();
// schema resolver has checked before that only one spec exists
final WatermarkSpec watermarkSpec = schema.getWatermarkSpecs().get(0);
final String rowtimeColumn = watermarkSpec.getRowtimeAttribute();
final int rowtimeColumnIdx = inputRelDataType.getFieldNames().indexOf(rowtimeColumn);
final RexNode watermarkRexNode = watermarkSpec.getWatermarkExpression().accept(converter);
relBuilder.watermark(rowtimeColumnIdx, watermarkRexNode);
}
Aggregations