예제 #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);
 }
 public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
   final SqlWriter.Frame frame = writer.startFunCall(getName());
   call.operand(0).unparse(writer, leftPrec, rightPrec);
   writer.sep("FROM");
   call.operand(1).unparse(writer, leftPrec, rightPrec);
   writer.endFunCall(frame);
 }
  public SqlRexConvertlet get(SqlCall call) {
    SqlRexConvertlet convertlet;
    final SqlOperator op = call.getOperator();

    // Is there a convertlet for this operator
    // (e.g. SqlStdOperatorTable.plusOperator)?
    convertlet = (SqlRexConvertlet) map.get(op);
    if (convertlet != null) {
      return convertlet;
    }

    // Is there a convertlet for this class of operator
    // (e.g. SqlBinaryOperator)?
    Class<? extends Object> clazz = op.getClass();
    while (clazz != null) {
      convertlet = (SqlRexConvertlet) map.get(clazz);
      if (convertlet != null) {
        return convertlet;
      }
      clazz = clazz.getSuperclass();
    }

    // Is there a convertlet for this class of expression
    // (e.g. SqlCall)?
    clazz = call.getClass();
    while (clazz != null) {
      convertlet = (SqlRexConvertlet) map.get(clazz);
      if (convertlet != null) {
        return convertlet;
      }
      clazz = clazz.getSuperclass();
    }
    return null;
  }
 public Void visit(SqlCall call) {
   final SqlOperator operator = call.getOperator();
   if (operator == SqlStdOperatorTable.andOperator) {
     throw new Found();
   }
   return super.visit(call);
 }
예제 #5
0
 // Override to copy all arguments regardless of whether visitor changes
 // them.
 protected SqlNode visitScoped(SqlCall call) {
   ArgHandler<SqlNode> argHandler = new CallCopyingArgHandler(call, true);
   call.getOperator().acceptCall(this, call, false, argHandler);
   return argHandler.result();
 }
예제 #6
0
 public void unparse(
     SqlWriter writer, SqlOperator operator, SqlCall call, int leftPrec, int rightPrec) {
   assert call.operandCount() == 1;
   call.operand(0).unparse(writer, operator.getLeftPrec(), operator.getRightPrec());
   writer.keyword(operator.getName());
 }