ehds commented on code in PR #3986:
URL: https://github.com/apache/calcite/pull/3986#discussion_r1810870230
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1719,6 +1725,46 @@ class TableFunctionScanContext extends BaseContext {
}
}
+
+ /**
+ * Context for translating call of a WindowTableFunction from {@link
RexNode} to
+ * {@link SqlNode}.*/
+ class WindowTableFunctionScanContext extends BaseContext {
+ private final SqlNode inputTableNode;
+ private final List<SqlNode> inputFieldNodes;
+
+ WindowTableFunctionScanContext(SqlDialect dialect,
+ SqlNode inputTableNode,
+ List<SqlNode> inputFieldNodes) {
+ super(dialect, inputFieldNodes.size());
+ this.inputFieldNodes = inputFieldNodes;
+ this.inputTableNode = inputTableNode;
+ }
+
+ @Override public SqlNode field(int ordinal) {
+ return inputFieldNodes.get(ordinal);
+ }
+
+ private boolean isWindowTableFunctionRex(RexNode rex) {
+ return (rex instanceof RexCall)
+ && (((RexCall) rex).getOperator() instanceof SqlWindowTableFunction);
+ }
+
+ @Override public SqlNode toSql(@Nullable RexProgram program, RexNode rex) {
+ if (isWindowTableFunctionRex(rex)) {
+ // Convert SqlWindowTableFunction operator without the PARAM_DATA to
sqlNode.
+ SqlNode callNode = super.toSql(null, rex);
+ // Reconstruct the callNode with inputTableNode as the PARAM_DATA.
+ List<SqlNode> operandList = new ArrayList<>();
+ operandList.add(inputTableNode);
+ operandList.addAll(((SqlBasicCall) callNode).getOperandList());
+ callNode = new SqlBasicCall(((SqlBasicCall) callNode).getOperator(),
operandList, POS);
Review Comment:
Thanks for the suggestion, done.
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1286,13 +1289,31 @@ public Result visit(Uncollect e) {
public Result visit(TableFunctionScan e) {
final List<SqlNode> inputSqlNodes = new ArrayList<>();
+ final List<SqlNode> fieldNodes = new ArrayList<>();
+
+ final int filedCount = e.getRowType().getFieldCount();
Review Comment:
done.
--
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]