private AggregateInfo getHiveAggInfo(ASTNode aggAst, int aggFnLstArgIndx, RowResolver inputRR)
        throws SemanticException {
      List<RexNode> aggParameters = new ArrayList<>();
      for (int i = 1; i <= aggFnLstArgIndx; i++) {
        RexNode parameterExpr = genRexNode(
            (ASTNode) aggAst.getChild(i), inputRR, cluster.getRexBuilder());
        aggParameters.add(parameterExpr);
      }
      boolean isDistinct = aggAst.getType() == HiveParser.TOK_FUNCTIONDI;
      boolean isAllColumns = aggAst.getType() == HiveParser.TOK_FUNCTIONSTAR;
      String aggName = unescapeIdentifier(aggAst.getChild(0).getText());

      AggregateInfo aInfo = functionHelper.getWindowAggregateFunctionInfo(
          isDistinct, isAllColumns, aggName, aggParameters);

      // If that did not work, try GenericUDF translation
      if (aInfo == null) {
        TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR, cluster.getRexBuilder());
        // We allow stateful functions in the SELECT list (but nowhere else)
        tcCtx.setAllowStatefulFunctions(true);
        tcCtx.setAllowDistinctFunctions(false);
        tcCtx.setUnparseTranslator(unparseTranslator);
        RexNode exp = genRexNode((ASTNode) aggAst.getChild(0), inputRR, tcCtx, conf);
        aInfo = new AggregateInfo(
            aggParameters, TypeConverter.convert(exp.getType()), aggName, isDistinct);
      }

      return aInfo;
    }
This method creates a HiveFilter containing a filter expression to enforce constraints.
Constraints to check: not null, check
The return value is the pair of Constraint HiveFilter and the corresponding RowResolver
or null if the target has no constraint defined or all of them are disabled.
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java