scarlin-cloudera commented on code in PR #4442: URL: https://github.com/apache/hive/pull/4442#discussion_r1244458166
########## ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/reloperators/HiveTableFunctionScan.java: ########## @@ -49,22 +57,43 @@ public class HiveTableFunctionScan extends TableFunctionScan implements HiveRelN * columnMappings - Column mappings associated with this function */ private HiveTableFunctionScan(RelOptCluster cluster, RelTraitSet traitSet, List<RelNode> inputs, - RexNode rexCall, Type elementType, RelDataType rowType, Set<RelColumnMapping> columnMappings) { + RexNode rexCall, Type elementType, RelDataType rowType, Set<RelColumnMapping> columnMappings, + boolean isLateralView) { super(cluster, traitSet, inputs, rexCall, elementType, rowType, columnMappings); + this.isLateralView = isLateralView; + } + + public static HiveTableFunctionScan create(RelOptCluster cluster, RelTraitSet traitSet, + List<RelNode> inputs, RexNode rexCall, Type elementType, RelDataType rowType, + Set<RelColumnMapping> columnMappings, boolean isLateralView) throws CalciteSemanticException { + return new HiveTableFunctionScan(cluster, traitSet, + inputs, rexCall, elementType, rowType, columnMappings, isLateralView); } public static HiveTableFunctionScan create(RelOptCluster cluster, RelTraitSet traitSet, List<RelNode> inputs, RexNode rexCall, Type elementType, RelDataType rowType, Set<RelColumnMapping> columnMappings) throws CalciteSemanticException { return new HiveTableFunctionScan(cluster, traitSet, - inputs, rexCall, elementType, rowType, columnMappings); + inputs, rexCall, elementType, rowType, columnMappings, false); } @Override public TableFunctionScan copy(RelTraitSet traitSet, List<RelNode> inputs, RexNode rexCall, Type elementType, RelDataType rowType, Set<RelColumnMapping> columnMappings) { return new HiveTableFunctionScan(getCluster(), traitSet, inputs, rexCall, - elementType, rowType, columnMappings); + elementType, rowType, columnMappings, isLateralView); + } + + // return the field in the return type where the udtf field starts. If it is not + // a lateral view, the first field in the return type is the udtf return field. + // Otherwise, we can subtract from the end the amount of udtf fields and the rest + // are from the input ref. + public int getStartUdtfField() { + return isLateralView() + ? getRowType().getFieldCount() - getCall().getType().getFieldCount() : 0; 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org