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

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


      }
     
      /*
       * validate and setup patternStr
       */
      ArgDef symboPatternArg = args.get(0);
      ObjectInspector symbolPatternArgOI = symboPatternArg.getOI();
     
      if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolPatternArgOI) ||
          (symbolPatternArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
          ((PrimitiveObjectInspector)symbolPatternArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING )
      {
        throwErrorWithSignature("Currently the symbol Pattern must be a Constant String.");
      }
     
      evaluator.patternStr = ((ConstantObjectInspector)symbolPatternArgOI).getWritableConstantValue().toString();
     
      /*
       * validate and setup SymbolInfo
       */
      int symbolArgsSz = argsNum - 2;
      if ( symbolArgsSz % 2 != 0)
      {
        throwErrorWithSignature("Symbol Name, Expression need to be specified in pairs: there are odd number of symbol args");
      }
     
      evaluator.symInfo = new SymbolsInfo(symbolArgsSz/2);
      for(int i=1; i <= symbolArgsSz; i += 2)
      {
        ArgDef symbolNameArg = args.get(i);
        ObjectInspector symbolNameArgOI = symbolNameArg.getOI();
       
        if ( !ObjectInspectorUtils.isConstantObjectInspector(symbolNameArgOI) ||
            (symbolNameArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
            ((PrimitiveObjectInspector)symbolNameArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING )
        {
          throwErrorWithSignature(sprintf("Currently a Symbol Name(%s) must be a Constant String", symbolNameArg.getExpression().toStringTree()));
        }
        String symbolName = ((ConstantObjectInspector)symbolNameArgOI).getWritableConstantValue().toString();
       
        ArgDef symolExprArg = args.get(i+1);
        ObjectInspector symolExprArgOI = symolExprArg.getOI();
        if ( (symolExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
              ((PrimitiveObjectInspector)symolExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.BOOLEAN )
        {
          throwErrorWithSignature(sprintf("Currently a Symbol Expression(%s) must be a boolean expression", symolExprArg.getExpression().toStringTree()));
        }
        evaluator.symInfo.add(symbolName, symolExprArg);
      }
     
      /*
       * validate and setup resultExprStr
       */
      ArgDef resultExprArg = args.get(argsNum - 1);
      ObjectInspector resultExprArgOI = resultExprArg.getOI();
     
      if ( !ObjectInspectorUtils.isConstantObjectInspector(resultExprArgOI) ||
            (resultExprArgOI.getCategory() != ObjectInspector.Category.PRIMITIVE) ||
            ((PrimitiveObjectInspector)resultExprArgOI).getPrimitiveCategory() != PrimitiveObjectInspector.PrimitiveCategory.STRING )
      {
View Full Code Here


    ArrayList<ASTNode> args = wFnSpec.getArgs();
    if ( args != null)
    {
      for(ASTNode expr : args)
      {
        ArgDef argDef = translateWindowFunctionArg(qDef, windowTableFnDef, iInfo,  expr);
        wFnDef.addArg(argDef);
      }
    }
   
    if ( RANKING_FUNCS.contains(wFnSpec.getName()))
View Full Code Here

    ArrayList<ASTNode> args = tSpec.getArgs();
    if ( args != null)
    {
      for(ASTNode expr : args)
      {
        ArgDef argDef = translateTableFunctionArg(qDef, tDef, iInfo,  expr);
        tDef.addArg(argDef);
      }
    }
   
    tFn.initialize(qDef, tDef);
View Full Code Here

  }

  public static ArgDef buildArgDef(QueryDef qDef, InputInfo iInfo, ASTNode arg)
      throws WindowingException
  {
    ArgDef argDef = new ArgDef();

    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(arg,
        iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(
        qDef.getTranslationInfo(), exprNode);
    ObjectInspector oi = initExprNodeEvaluator(qDef, exprNode, exprEval,
        iInfo);

    argDef.setExpression(arg);
    argDef.setExprNode(exprNode);
    argDef.setExprEvaluator(exprEval);
    argDef.setOI(oi);
    return argDef;
  }
View Full Code Here

    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();
View Full Code Here

 

  public static ColumnDef translateSelectExpr(QueryDef qDef, InputInfo iInfo, int colIdx, String alias, ASTNode expr)
    throws WindowingException
  {
    ColumnDef cDef = new ColumnDef((ColumnSpec) null);
    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(expr, iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), exprNode);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
   
    cDef.setExpression(expr);
    cDef.setExprNode(exprNode);
    cDef.setExprEvaluator(exprEval);
    cDef.setOI(oi);
   
    cDef.setAlias(getAlias(alias, expr, colIdx));
   
    return cDef;
  }
View Full Code Here

    ObjectInspector[] keyOIs = new ObjectInspector[numCols];
    ObjectInspector[] currentKeyOIs = new ObjectInspector[numCols];
   
    for(int i=0; i<numCols; i++)
    {
      ColumnDef cDef = cols.get(i);
      /*
       * Why cannot we just use the ExprNodeEvaluator on the column?
       * - because on the reduce-side it is initialized based on the rowOI of the HiveTable
       *   and not the OI of the ExtractOp ( the parent of this Operator on the reduce-side)
       */
      keyFields[i] = ExprNodeEvaluatorFactory.get(cDef.getExprNode());
      keyOIs[i] = keyFields[i].initialize(inputOI);
      currentKeyOIs[i] = ObjectInspectorUtils.getStandardObjectInspector(keyOIs[i], ObjectInspectorCopyOption.WRITABLE);
    }
   
    keyWrapperFactory = new WindowingKeyWrapperFactory(keyFields, keyOIs, currentKeyOIs);
View Full Code Here

    return serdePropsMap;
  }
 
  private static HiveQueryDef translate(QueryDef qDef, HiveQuerySpec spec) throws WindowingException
  {
    HiveQueryDef def = new HiveQueryDef();
    HiveQueryExecutor hiveQryExec = qDef.getTranslationInfo().getHiveQueryExecutor();
    Hive hive = qDef.getTranslationInfo().getHive();
   
    String tableName = hiveQryExec.createTableAsQuery(spec.getHiveQuery());
    HiveTableSpec tSpec = new HiveTableSpec();
View Full Code Here

 
  private static String getTableAlias(QueryDef qDef, int inputNum, QueryInputDef inputDef) throws WindowingException
  {
    if ( inputDef instanceof HiveTableDef)
    {
      HiveTableDef hTbldef = (HiveTableDef) inputDef;
      String db = ((HiveTableSpec)hTbldef.getSpec()).getDbName();
      String tableName = ((HiveTableSpec)hTbldef.getSpec()).getTableName();
      return db + "." + tableName;
    }
    else if ( inputDef instanceof TableFuncDef)
    {
      return "ptf_" + inputNum;
View Full Code Here

  }

  private static HiveTableDef translate(QueryDef qDef, HiveTableSpec spec,
      HiveTableDef def) throws WindowingException
  {
    def = def == null ? new HiveTableDef() : def;
    HiveMetaStoreClient hiveMSC = qDef.getTranslationInfo()
        .getHiveMSClient();
    Hive hive = qDef.getTranslationInfo().getHive();

    def.setSpec(spec);
View Full Code Here

TOP

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

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.