Пример #1
0
 public Void visit(SqlCall call) {
   final SqlOperator operator = call.getOperator();
   if (operator.isAggregator()) {
     throw new Util.FoundOne(call);
   }
   // User-defined function may not be resolved yet.
   if (operator instanceof SqlFunction
       && ((SqlFunction) operator).getFunctionType()
           == SqlFunctionCategory.USER_DEFINED_FUNCTION) {
     final List<SqlOperator> list = Lists.newArrayList();
     opTab.lookupOperatorOverloads(
         ((SqlFunction) operator).getSqlIdentifier(),
         SqlFunctionCategory.USER_DEFINED_FUNCTION,
         SqlSyntax.FUNCTION,
         list);
     for (SqlOperator sqlOperator : list) {
       if (sqlOperator.isAggregator()) {
         throw new Util.FoundOne(call);
       }
     }
   }
   if (call.isA(SqlKind.QUERY)) {
     // don't traverse into queries
     return null;
   }
   if (call.getKind() == SqlKind.OVER) {
     if (over) {
       throw new Util.FoundOne(call);
     } else {
       // an aggregate function over a window is not an aggregate!
       return null;
     }
   }
   return super.visit(call);
 }
Пример #2
0
 /**
  * Constructs a FarragoReentrantSubquery.
  *
  * @param subq the subquery to evaluate
  * @param parentConverter sqlToRelConverter associated with the parent query
  * @param isExists whether the subquery is part of an EXISTS expression
  * @param isExplain whether the subquery is part of an EXPLAIN PLAN statement
  * @param results the resulting evaluated expressions
  */
 FarragoReentrantSubquery(
     SqlCall subq,
     SqlToRelConverter parentConverter,
     boolean isExists,
     boolean isExplain,
     List<RexNode> results) {
   super(
       FennelRelUtil.getPreparingStmt(parentConverter.getCluster()).getRootStmtContext(),
       parentConverter.getRexBuilder(),
       results);
   FarragoSessionStmtContext rootContext = getRootStmtContext();
   if (rootContext != null) {
     rootContext.setSaveFirstTxnCsn();
   }
   if (!isExists) {
     assert subq.getKind() == SqlKind.SCALAR_QUERY;
   }
   this.subq = subq;
   this.parentConverter = parentConverter;
   this.isExists = isExists;
   this.isExplain = isExplain;
 }