Source:
protected void convertCollectionTable( Blackboard bb, SqlCall call) { final SqlOperator operator = call.getOperator(); if (operator == SqlStdOperatorTable.TABLESAMPLE) { final String sampleName = SqlLiteral.unchain(call.operand(0)).getValueAs(String.class); datasetStack.push(sampleName); SqlCall cursorCall = call.operand(1); SqlNode query = cursorCall.operand(0); RelNode converted = convertQuery(query, false, false).rel; bb.setRoot(converted, false); datasetStack.pop(); return; } replaceSubQueries(bb, call, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN); final SqlCallBinding callBinding = new SqlCallBinding(bb.scope.getValidator(), bb.scope, call); if (operator instanceof SqlUserDefinedTableMacro) { final SqlUserDefinedTableMacro udf = (SqlUserDefinedTableMacro) operator; final TranslatableTable table = udf.getTable(typeFactory, callBinding.operands()); final RelDataType rowType = table.getRowType(typeFactory); RelOptTable relOptTable = RelOptTableImpl.create(null, rowType, table, udf.getNameAsId().names); RelNode converted = toRel(relOptTable, null); bb.setRoot(converted, true); return; } Type elementType; if (operator instanceof SqlUserDefinedTableFunction) { SqlUserDefinedTableFunction udtf = (SqlUserDefinedTableFunction) operator; elementType = udtf.getElementType(typeFactory, callBinding.operands()); } else { elementType = null; } RexNode rexCall = bb.convertExpression(call); List<RelNode> inputs = new ArrayList<>(); if (rexCall.getKind() == SqlKind.TUMBLE) { inputs.add(convertSelect((SqlSelect) call.getOperandList().get(0), false)); } else { inputs = bb.retrieveCursors(); } Set<RelColumnMapping> columnMappings = getColumnMappings(operator); LogicalTableFunctionScan callRel = LogicalTableFunctionScan.create( cluster, inputs, rexCall, elementType, validator.getValidatedNodeType(call), columnMappings); bb.setRoot(callRel, true); afterTableFunction(bb, call, callRel); }

Target:
protected void convertCollectionTable( Blackboard bb, SqlCall call) { final SqlOperator operator = call.getOperator(); if (operator == SqlStdOperatorTable.TABLESAMPLE) { final String sampleName = SqlLiteral.unchain(call.operand(0)).getValueAs(String.class); datasetStack.push(sampleName); SqlCall cursorCall = call.operand(1); SqlNode query = cursorCall.operand(0); RelNode converted = convertQuery(query, false, false).rel; bb.setRoot(converted, false); datasetStack.pop(); return; } replaceSubQueries(bb, call, RelOptUtil.Logic.TRUE_FALSE_UNKNOWN); final SqlCallBinding callBinding = new SqlCallBinding(bb.scope.getValidator(), bb.scope, call); if (operator instanceof SqlUserDefinedTableMacro) { final SqlUserDefinedTableMacro udf = (SqlUserDefinedTableMacro) operator; final TranslatableTable table = udf.getTable(typeFactory, callBinding.operands()); final RelDataType rowType = table.getRowType(typeFactory); RelOptTable relOptTable = RelOptTableImpl.create(null, rowType, table, udf.getNameAsId().names); RelNode converted = toRel(relOptTable, null); bb.setRoot(converted, true); return; } Type elementType; if (operator instanceof SqlUserDefinedTableFunction) { SqlUserDefinedTableFunction udtf = (SqlUserDefinedTableFunction) operator; elementType = udtf.getElementType(typeFactory, callBinding.operands()); } else { elementType = null; } RexNode rexCall = bb.convertExpression(call); final List<RelNode> inputs = bb.retrieveCursors(); Set<RelColumnMapping> columnMappings = getColumnMappings(operator); LogicalTableFunctionScan callRel = LogicalTableFunctionScan.create( cluster, inputs, rexCall, elementType, validator.getValidatedNodeType(call), columnMappings); bb.setRoot(callRel, true); afterTableFunction(bb, call, callRel); }