Examples of SelectDesc


Examples of org.apache.hadoop.hive.ql.plan.SelectDesc

    assert(op.columnNamesRowResolvedCanBeObtained());
    // Only select operators among the allowed operators can cause changes in the
    // column names
    if (op instanceof SelectOperator) {
      SelectDesc selectDesc = ((SelectOperator)op).getConf();
      if (!selectDesc.isSelStarNoCompute()) {
        colList = selectDesc.getColList();
        outputColNames = selectDesc.getOutputColumnNames();

        // Only columns and constants can be selected
        for (int pos = 0; pos < colList.size(); pos++) {
          ExprNodeDesc colExpr = colList.get(pos);
          String outputColName = outputColNames.get(pos);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.SelectDesc

      outputRS.put(nm[0], nm[1], new ColumnInfo(internalName, valueInfo.getType(), nm[0], valueInfo
          .getIsVirtualCol(), valueInfo.isHiddenVirtualCol()));
      colExprMap.put(internalName, colDesc);
    }

    SelectDesc select = new SelectDesc(exprs, outputs, false);

    SelectOperator sel = (SelectOperator) putOpInsertMap(OperatorFactory.getAndMakeChild(select,
        new RowSchema(inputRR.getColumnInfos()), input), inputRR);

    sel.setColumnExprMap(colExprMap);
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.SelectDesc

        currOp = (Operator<? extends OperatorDesc>) (stack.get(++stackPos));

        // Filters don't change the column names - so, no need to do anything for them
        if (processOp instanceof SelectOperator) {
          SelectOperator selectOp = (SelectOperator) processOp;
          SelectDesc selectDesc = selectOp.getConf();

          if (selectDesc.isSelStarNoCompute()) {
            continue;
          }

          // Only columns and constants can be selected
          for (int pos = 0; pos < selectDesc.getColList().size(); pos++) {
            String outputColumnName = selectDesc.getOutputColumnNames().get(pos);
            if (constantCols.contains(outputColumnName)) {
              tableColsMapping.remove(outputColumnName);
              newConstantCols.add(outputColumnName);
              continue;
            }

            ExprNodeDesc selectColList = selectDesc.getColList().get(pos);
            if (selectColList instanceof ExprNodeColumnDesc) {
              String newValue =
                  tableColsMapping.get(((ExprNodeColumnDesc) selectColList).getColumn());
              tableColsMapping.put(outputColumnName, newValue);
            }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.SelectDesc

          }
        }
      }
      List<String> cols = cppCtx.genColLists(op);

      SelectDesc conf = op.getConf();

      if (lvJoin != null) {
        // get columns for SEL(*) from LVJ
        RowResolver rr = cppCtx.getOpToParseCtxMap().get(op).getRowResolver();
        cppCtx.getPrunedColLists().put(op, cppCtx.getSelectColsFromLVJoin(rr, cols));
        return null;
      }
      // The input to the select does not matter. Go over the expressions
      // and return the ones which have a marked column
      cppCtx.getPrunedColLists().put(op,
          cppCtx.getSelectColsFromChildren(op, cols));

      if (conf.isSelStarNoCompute()) {
        return null;
      }

      // do we need to prune the select operator?
      List<ExprNodeDesc> originalColList = op.getConf().getColList();
      List<String> columns = new ArrayList<String>();
      for (ExprNodeDesc expr : originalColList) {
        Utilities.mergeUniqElems(columns, expr.getCols());
      }
      // by now, 'prunedCols' are columns used by child operators, and 'columns'
      // are columns used by this select operator.
      List<String> originalOutputColumnNames = conf.getOutputColumnNames();
      if (cols.size() < originalOutputColumnNames.size()) {
        ArrayList<ExprNodeDesc> newColList = new ArrayList<ExprNodeDesc>();
        ArrayList<String> newOutputColumnNames = new ArrayList<String>();
        ArrayList<ColumnInfo> rs_oldsignature = op.getSchema().getSignature();
        ArrayList<ColumnInfo> rs_newsignature = new ArrayList<ColumnInfo>();
        RowResolver old_rr = cppCtx.getOpToParseCtxMap().get(op).getRowResolver();
        RowResolver new_rr = new RowResolver();
        for (String col : cols) {
          int index = originalOutputColumnNames.indexOf(col);
          newOutputColumnNames.add(col);
          newColList.add(originalColList.get(index));
          rs_newsignature.add(rs_oldsignature.get(index));
          String[] tabcol = old_rr.reverseLookup(col);
          ColumnInfo columnInfo = old_rr.get(tabcol[0], tabcol[1]);
          new_rr.put(tabcol[0], tabcol[1], columnInfo);
        }
        cppCtx.getOpToParseCtxMap().get(op).setRowResolver(new_rr);
        op.getSchema().setSignature(rs_newsignature);
        conf.setColList(newColList);
        conf.setOutputColumnNames(newOutputColumnNames);
        handleChildren(op, cols, cppCtx);
      }
      return null;
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

   * @param op The select operator.
   * @return List<String> of the internal column names.
   */
  public List<String> getColsFromSelectExpr(SelectOperator op) {
    List<String> cols = new ArrayList<String>();
    selectDesc conf = op.getConf();
    ArrayList<exprNodeDesc> exprList = conf.getColList();
    for (exprNodeDesc expr : exprList)
      cols = Utilities.mergeUniqElems(cols, expr.getCols());
    return cols;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

   * @param colList The list of internal column names returned by the children of the select operator.
   * @return List<String> of the internal column names.
   */
  public List<String> getSelectColsFromChildren(SelectOperator op, List<String> colList) {
    List<String> cols = new ArrayList<String>();
    selectDesc conf = op.getConf();
    ArrayList<exprNodeDesc> selectExprs = conf.getColList();

    for (String col : colList) {
      // col is the internal name i.e. position within the expression list
      exprNodeDesc expr = selectExprs.get(Integer.parseInt(col));
      cols = Utilities.mergeUniqElems(cols, expr.getCols());
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

                   new ColumnInfo((Integer.valueOf(pos)).toString(), in.getType()));
      col_list.add(new exprNodeColumnDesc(in.getType(), internalName));
    }

    Operator output = putOpInsertMap(OperatorFactory.getAndMakeChild(
      new selectDesc(col_list), new RowSchema(outputRR.getColumnInfos()), input), outputRR);

    return output;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

          }
          cols = Utilities.mergeUniqElems(cols, cppCtx.getPrunedColLists().get(child));
        }
      }

      selectDesc conf = op.getConf();
      if (conf.isSelectStar() && !cols.isEmpty()) {
        // The input to the select does not matter. Go over the expressions
        // and return the ones which have a marked column
        cppCtx.getPrunedColLists().put(op, cppCtx.getSelectColsFromChildren(op, cols));
        return null;
      }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

          }
        }
      }
      cols = cppCtx.genColLists(op);

      selectDesc conf = op.getConf();
      // The input to the select does not matter. Go over the expressions
      // and return the ones which have a marked column
      cppCtx.getPrunedColLists().put(op, cppCtx.getSelectColsFromChildren(op, cols));
     
      if(conf.isSelStarNoCompute())
        return null;
     
      // do we need to prune the select operator?
      List<exprNodeDesc> originalColList = op.getConf().getColList();
      List<String> columns = new ArrayList<String>();
      for (exprNodeDesc expr : originalColList)
        Utilities.mergeUniqElems(columns, expr.getCols());
      // by now, 'prunedCols' are columns used by child operators, and 'columns'
      // are columns used by this select operator.
      ArrayList<String> originalOutputColumnNames = conf.getOutputColumnNames();
      if (cols.size() < originalOutputColumnNames.size()) {
        ArrayList<exprNodeDesc> newColList = new ArrayList<exprNodeDesc>();
        ArrayList<String> newOutputColumnNames = new ArrayList<String>();
        Vector<ColumnInfo> rs_oldsignature = op.getSchema().getSignature();
        Vector<ColumnInfo> rs_newsignature = new Vector<ColumnInfo>();
        RowResolver old_rr = cppCtx.getOpToParseCtxMap().get(op).getRR();
        RowResolver new_rr = new RowResolver();
        for(String col : cols){
          int index = originalOutputColumnNames.indexOf(col);
          newOutputColumnNames.add(col);
          newColList.add(originalColList.get(index));
          rs_newsignature.add(rs_oldsignature.get(index));
          String[] tabcol = old_rr.reverseLookup(col);
          ColumnInfo columnInfo = old_rr.get(tabcol[0], tabcol[1]);
          new_rr.put(tabcol[0], tabcol[1], columnInfo);
        }
        cppCtx.getOpToParseCtxMap().get(op).setRR(new_rr);
        op.getSchema().setSignature(rs_newsignature);
        conf.setColList(newColList);
        conf.setOutputColumnNames(newOutputColumnNames);
        handleChildren(op, cols, cppCtx);
      }
      return null;
    }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.plan.selectDesc

      outputRS .put(nm[0], nm[1], new ColumnInfo(internalName,
          valueInfo.getType(), nm[0], valueInfo.getIsPartitionCol()));
      colExprMap.put(internalName, colDesc);
    }
   
    selectDesc select = new selectDesc(exprs, outputs, false);
   
    SelectOperator sel =
      (SelectOperator)putOpInsertMap(OperatorFactory.getAndMakeChild(
          select, new RowSchema(inputRR.getColumnInfos()), input), inputRR);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.