private RelDataType getRetType(RelOptCluster cluster, RelNode inputRel,
      RexNode udtfCall, List<String> columnAliases) {

    // initialize allDataTypes and allDataTypeNames from the fields in the inputRel
    List<RelDataType> allDataTypes = new ArrayList<>( Lists.transform(inputRel.getRowType().getFieldList(), RelDataTypeField::getType));
    List<String> allDataTypeNames = new ArrayList<>(
        Lists.transform(inputRel.getRowType().getFieldList(), RelDataTypeField::getName));

    RelDataType retType = udtfCall.getType();

    Preconditions.checkState(retType.isStruct());

    // Add the type names and values from the udtf into the lists that will make up the
    // return type. Names need to be unique so add the table prefix
    allDataTypes.addAll(Lists.transform(retType.getFieldList(), RelDataTypeField::getType));
    for (String s : columnAliases) {
      allDataTypeNames.add(lateralTableAlias + "." + s);
    }

    return cluster.getTypeFactory().createStructType(allDataTypes, allDataTypeNames);
  }
get the return type for the lateral view. The return type will be a structure
where the first values are from the input RelNode. Then the output values from the
udtf will be added into the structure for the return type.
ql/src/java/org/apache/hadoop/hive/ql/parse/relnodegen/LateralViewPlan.java