twalthr commented on code in PR #30016:
URL: https://github.com/apache/flink/pull/30016#discussion_r4640287995
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -441,6 +444,48 @@ private RelNode visitCorrelate(FlinkLogicalCorrelate
correlate) {
correlate.getJoinType());
}
+ private RelNode visitTableFunctionScan(FlinkLogicalTableFunctionScan scan)
{
+ final FlinkLogicalTableFunctionScan newScan =
+ (FlinkLogicalTableFunctionScan) visitSimpleRel(scan);
+ final RexCall call = (RexCall) newScan.getCall();
+ if (!ShortcutUtils.isFunctionKind(call.getOperator(),
FunctionKind.PROCESS_TABLE)
+ || !gatherProcTimeIndices(scan).isEmpty()) {
+ return newScan;
+ }
+ // Proctime is only computed on access, so a PTF that does not forward
it needs its value
+ final List<RelNode> newInputs =
+ newScan.getInputs().stream()
+ .map(this::materializeProcTime)
+ .collect(Collectors.toList());
+ final List<RexNode> newOperands =
+ call.getOperands().stream()
+ .map(
+ operand ->
+ operand instanceof RexTableArgCall
+ ? withInputType(
+ (RexTableArgCall)
operand, newInputs)
+ : operand)
+ .collect(Collectors.toList());
+ return newScan.copy(
+ newScan.getTraitSet(),
+ newInputs,
+ call.clone(call.getType(), newOperands),
+ newScan.getElementType(),
+ newScan.getRowType(),
+ newScan.getColumnMappings());
+ }
+
+ private RexNode withInputType(RexTableArgCall tableArg, List<RelNode>
inputs) {
Review Comment:
```suggestion
private RexNode adjustTableArg(RexTableArgCall tableArg, List<RelNode>
inputs) {
```
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/SystemTypeInference.java:
##########
@@ -403,12 +404,19 @@ public Optional<DataType> inferType(CallContext
callContext) {
// - Flink SESSION windows add pass-through
columns at the beginning
// - Oracle adds pass-through columns for all
ROW semantics args, so
// this whole topic is kind of vendor specific
already
+ final List<Field> rowtimeFields =
+ disableSystemArgs
+ ? List.of()
+ :
deriveRowtimeField(callContext, resolvedArgs);
+ // The on_time rowtime replaces any forwarded
time attribute
Review Comment:
in theory we could allow both, there is no limitation of multiple time
attributes per row. would maybe simplify things?
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/calcite/RelTimeIndicatorConverter.java:
##########
@@ -441,6 +444,48 @@ private RelNode visitCorrelate(FlinkLogicalCorrelate
correlate) {
correlate.getJoinType());
}
+ private RelNode visitTableFunctionScan(FlinkLogicalTableFunctionScan scan)
{
+ final FlinkLogicalTableFunctionScan newScan =
+ (FlinkLogicalTableFunctionScan) visitSimpleRel(scan);
+ final RexCall call = (RexCall) newScan.getCall();
+ if (!ShortcutUtils.isFunctionKind(call.getOperator(),
FunctionKind.PROCESS_TABLE)
+ || !gatherProcTimeIndices(scan).isEmpty()) {
+ return newScan;
+ }
+ // Proctime is only computed on access, so a PTF that does not forward
it needs its value
+ final List<RelNode> newInputs =
+ newScan.getInputs().stream()
+ .map(this::materializeProcTime)
+ .collect(Collectors.toList());
+ final List<RexNode> newOperands =
+ call.getOperands().stream()
+ .map(
+ operand ->
+ operand instanceof RexTableArgCall
+ ? withInputType(
+ (RexTableArgCall)
operand, newInputs)
+ : operand)
+ .collect(Collectors.toList());
+ return newScan.copy(
+ newScan.getTraitSet(),
+ newInputs,
+ call.clone(call.getType(), newOperands),
+ newScan.getElementType(),
+ newScan.getRowType(),
+ newScan.getColumnMappings());
+ }
+
+ private RexNode withInputType(RexTableArgCall tableArg, List<RelNode>
inputs) {
+ final RelDataType inputType =
inputs.get(tableArg.getInputIndex()).getRowType();
+ return tableArg.clone(
+ rexBuilder
+ .getTypeFactory()
+ .createStructType(
Review Comment:
Double check if the StructKind is preserved
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]