Package com.sap.hadoop.windowing.query2.translate

Examples of com.sap.hadoop.windowing.query2.translate.WindowFunctionTranslation


  }
 
  @Test
  public void testWindowClause() throws WindowingException
  {
    QueryDef qDef = wshell.translate("select  p_mfgr,p_name, p_size, " +
        "sum(p_size) over w1 as s, " +
        " denserank() as dr " +
        " from part_demo " +
        " partition by p_mfgr" +
        " window w1 as rows between 2 preceding and 2 following" +
        " into path='/tmp/wout2'" +
        " serde 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'" +
        " with serdeproperties('field.delim'=',')" +
        " format 'org.apache.hadoop.mapred.TextOutputFormat'");
   
    RangeBoundaryDef rBdef = (RangeBoundaryDef) qDef.getSelectList().getWindowFuncs().get(0).getWindow().getWindow().getStart();
    assert rBdef.getAmt() == 2;
    rBdef = (RangeBoundaryDef) qDef.getSelectList().getWindowFuncs().get(0).getWindow().getWindow().getEnd();
    assert rBdef.getAmt() == 2;
   
  }
View Full Code Here


  }

  public void execute(String query, QueryOutputPrinter outP) throws WindowingException
  {
    QuerySpec qSpec = parse(query);
    QueryDef q = translator.translate(qSpec, this);
   
    ArrayList<QueryDef> componentQueries;
    executor.beforeComponentization(q, this);
    QueryComponentizer qC = new QueryComponentizer(q, this);
    componentQueries = qC.componentize();
View Full Code Here

    if (wSpec.getArgs().size() > 0)
    {
      throw new WindowingException("Ranking Functions can take no arguments");
    }
   
    QueryInputDef inpDef = windowTableFnDef.getInput();
    InputInfo inpInfo = qDef.getTranslationInfo().getInputInfo(inpDef);
    OrderDef oDef = getTableFuncOrderDef(windowTableFnDef);
    ArrayList<OrderColumnDef> oCols = oDef.getColumns();
    for(OrderColumnDef oCol : oCols)
    {
View Full Code Here

  {
    if ( tblFnDef.getWindow() != null )
    {
      return tblFnDef.getWindow().getOrderDef();
    }
    QueryInputDef iDef = tblFnDef.getInput();
    if ( iDef instanceof TableFuncDef )
    {
      return getTableFuncOrderDef((TableFuncDef) iDef);
    }
    throw new WindowingException("No Order by specification on Function: " + tblFnDef.getSpec());
View Full Code Here

    }

    @Override
    public QueryInputDef next()
    {
      QueryInputDef curr = nextInput;
      if ( curr instanceof TableFuncDef)
      {
        TableFuncDef tFunc = (TableFuncDef) curr;
        nextInput = tFunc.getInput();
      }
View Full Code Here

    if ( wExpr == null ) return;
   
    WhereDef whDef = new WhereDef();
    whDef.setExpression(wExpr);
   
    QueryInputDef iDef = qDef.getInput();
    InputInfo iInfo = tInfo.getInputInfo(iDef);
   
    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(wExpr, iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(tInfo, exprNode);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
View Full Code Here

  }
 
  public static void translateSelectExprs(QueryDef qDef) throws WindowingException
  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QueryInputDef iDef = qDef.getInput();
    InputInfo iInfo = tInfo.getInputInfo(iDef);
    SelectDef selectDef = qDef.getSelectList();
    SelectSpec selectSpec = qDef.getSpec().getSelectList();
    Iterator<Object> selectExprsAndAliases = selectSpec.getColumnListAndAlias();
    int i = 0;
View Full Code Here

    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
   
    translateSelectExprs(qDef);
    validateOutputSpec(qDef);
   
    QueryOutputDef oDef = new QueryOutputDef();
    oDef.setOutputSpec(qDef.getSpec().getOutput());
    qDef.setOutput(oDef);
       
    setupOutputSerDe(tInfo.getHiveCfg(), qDef.getSelectList(), oDef);
   
  }
View Full Code Here

   * @return
   * @throws WindowingException
   */
  static TableDesc createOutputTableDesc(QueryDef qDef) throws WindowingException
  {
    QueryOutputDef oDef = qDef.getOutput();
    Class<? extends SerDe> serDeClass = oDef.getSerDe().getClass();
    Properties p = oDef.getSpec().getSerDeProps();
    String columnNamesList = p.getProperty(Constants.LIST_COLUMNS);
    String columnTypesList = p.getProperty(Constants.LIST_COLUMN_TYPES);
    String fieldSeparator = p.getProperty(Constants.FIELD_DELIM, Integer.toString(Utilities.ctrlaCode));
    return PlanUtils.getTableDesc(serDeClass, fieldSeparator,
            columnNamesList, columnTypesList, false);
View Full Code Here

  public static void translateSelectExprs(QueryDef qDef) throws WindowingException
  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QueryInputDef iDef = qDef.getInput();
    InputInfo iInfo = tInfo.getInputInfo(iDef);
    SelectDef selectDef = qDef.getSelectList();
    SelectSpec selectSpec = qDef.getSpec().getSelectList();
    Iterator<Object> selectExprsAndAliases = selectSpec.getColumnListAndAlias();
    int i = 0;
    ColumnDef cDef = null;
   
   
    while(selectExprsAndAliases.hasNext())
    {
      Object[] o = (Object[]) selectExprsAndAliases.next();
      boolean isWnFn = ((Boolean) o[0]).booleanValue();
     
      if ( isWnFn )
      {
        cDef = translateWindowFnAlias(qDef, iInfo, i++, (String) o[1]);
      }
      else
      {
        cDef = translateSelectExpr(qDef, iInfo, i++, (String) o[1], (ASTNode) o[2]);
      }
      selectDef.addColumn(cDef);
    }
    TranslateUtils.setupSelectOI(selectDef);
   
  }
View Full Code Here

TOP

Related Classes of com.sap.hadoop.windowing.query2.translate.WindowFunctionTranslation

Copyright © 2018 www.massapicom. 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.