示例#1
0
 /**
  * Finds an aggregate.
  *
  * @param node Parse tree to search
  * @return First aggregate function in parse tree, or null if not found
  */
 public SqlNode findAgg(SqlNode node) {
   try {
     node.accept(this);
     return null;
   } catch (Util.FoundOne e) {
     Util.swallow(e, null);
     return (SqlNode) e.getNode();
   }
 }
示例#2
0
文件: RexUtil.java 项目: kunlqt/optiq
 /** Returns whether an array of expressions has any common sub-expressions. */
 public static boolean containCommonExprs(RexNode[] exprs, boolean fail) {
   final ExpressionNormalizer visitor = new ExpressionNormalizer(false);
   for (int i = 0; i < exprs.length; i++) {
     try {
       exprs[i].accept(visitor);
     } catch (ExpressionNormalizer.SubExprExistsException e) {
       Util.swallow(e, null);
       assert !fail;
     }
   }
   return false;
 }
示例#3
0
文件: RexUtil.java 项目: kunlqt/optiq
 /**
  * Returns whether a given tree contains any {@link org.eigenbase.rex.RexFieldAccess} nodes.
  *
  * @param node a RexNode tree
  */
 public static boolean containsFieldAccess(RexNode node) {
   try {
     RexVisitor<Void> visitor =
         new RexVisitorImpl<Void>(true) {
           public Void visitFieldAccess(RexFieldAccess fieldAccess) {
             throw new Util.FoundOne(fieldAccess);
           }
         };
     node.accept(visitor);
     return false;
   } catch (Util.FoundOne e) {
     Util.swallow(e, null);
     return true;
   }
 }
示例#4
0
文件: RexUtil.java 项目: kunlqt/optiq
 /**
  * Returns whether a given tree contains any {link RexInputRef} nodes.
  *
  * @param node a RexNode tree
  */
 public static boolean containsInputRef(RexNode node) {
   try {
     RexVisitor<Void> visitor =
         new RexVisitorImpl<Void>(true) {
           public Void visitInputRef(RexInputRef inputRef) {
             throw new Util.FoundOne(inputRef);
           }
         };
     node.accept(visitor);
     return false;
   } catch (Util.FoundOne e) {
     Util.swallow(e, null);
     return true;
   }
 }
示例#5
0
文件: RexUtil.java 项目: kunlqt/optiq
 /**
  * Returns whether an array of expressions contains a forward reference. That is, if expression #i
  * contains a {@link RexInputRef} referencing field i or greater.
  *
  * @param exprs Array of expressions
  * @param inputRowType Input row type
  * @param fail Whether to assert if there is a forward reference
  * @return Whether there is a forward reference
  */
 public static boolean containForwardRefs(
     RexNode[] exprs, RelDataType inputRowType, boolean fail) {
   final ForwardRefFinder visitor = new ForwardRefFinder(inputRowType);
   for (int i = 0; i < exprs.length; i++) {
     RexNode expr = exprs[i];
     visitor.setLimit(i); // field cannot refer to self or later field
     try {
       expr.accept(visitor);
     } catch (ForwardRefFinder.IllegalForwardRefException e) {
       Util.swallow(e, null);
       assert !fail : "illegal forward reference in " + expr;
       return true;
     }
   }
   return false;
 }
示例#6
0
文件: RexUtil.java 项目: kunlqt/optiq
 /**
  * Returns whether a given node contains a RexCall with a specified operator
  *
  * @param operator to look for
  * @param node a RexNode tree
  */
 public static RexCall findOperatorCall(final SqlOperator operator, RexNode node) {
   try {
     RexVisitor<Void> visitor =
         new RexVisitorImpl<Void>(true) {
           public Void visitCall(RexCall call) {
             if (call.getOperator().equals(operator)) {
               throw new Util.FoundOne(call);
             }
             return super.visitCall(call);
           }
         };
     node.accept(visitor);
     return null;
   } catch (Util.FoundOne e) {
     Util.swallow(e, null);
     return (RexCall) e.getNode();
   }
 }