Java Code Examples for org.apache.calcite.sql.fun.SqlStdOperatorTable#OR

The following examples show how to use org.apache.calcite.sql.fun.SqlStdOperatorTable#OR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlNodeList.java    From Bats with Apache License 2.0 6 votes vote down vote up
void andOrList(SqlWriter writer, SqlKind sepKind) {
  SqlBinaryOperator sepOp =
      sepKind == SqlKind.AND
          ? SqlStdOperatorTable.AND
          : SqlStdOperatorTable.OR;
  for (int i = 0; i < list.size(); i++) {
    SqlNode node = list.get(i);
    writer.sep(sepKind.name(), false);

    // The precedence pulling on the LHS of a node is the
    // right-precedence of the separator operator, except at the start
    // of the list; similarly for the RHS of a node. If the operator
    // has left precedence 4 and right precedence 5, the precedences
    // in a 3-node list will look as follows:
    //   0 <- node1 -> 4  5 <- node2 -> 4  5 <- node3 -> 0
    int lprec = (i == 0) ? 0 : sepOp.getRightPrec();
    int rprec = (i == (list.size() - 1)) ? 0 : sepOp.getLeftPrec();
    node.unparse(writer, lprec, rprec);
  }
}
 
Example 2
Source File: SqlOperator.java    From calcite with Apache License 2.0 6 votes vote down vote up
@Deprecated // to be removed before 2.0
protected void unparseListClause(
    SqlWriter writer,
    SqlNode clause,
    SqlKind sepKind) {
  final SqlNodeList nodeList =
      clause instanceof SqlNodeList
          ? (SqlNodeList) clause
          : SqlNodeList.of(clause);
  final SqlBinaryOperator sepOp;
  if (sepKind == null) {
    sepOp = SqlWriter.COMMA;
  } else {
    switch (sepKind) {
    case AND:
      sepOp = SqlStdOperatorTable.AND;
      break;
    case OR:
      sepOp = SqlStdOperatorTable.OR;
      break;
    default:
      throw new AssertionError();
    }
  }
  writer.list(SqlWriter.FrameTypeEnum.SIMPLE, sepOp, nodeList);
}
 
Example 3
Source File: SqlBinaryOperator.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override public boolean validRexOperands(int count, Litmus litmus) {
  if (count != 2) {
    // Special exception for AND and OR.
    if ((this == SqlStdOperatorTable.AND
        || this == SqlStdOperatorTable.OR)
        && count > 2) {
      return true;
    }
    return litmus.fail("wrong operand count {} for {}", count, this);
  }
  return litmus.succeed();
}
 
Example 4
Source File: SqlBinaryOperator.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public boolean validRexOperands(int count, Litmus litmus) {
  if (count != 2) {
    // Special exception for AND and OR.
    if ((this == SqlStdOperatorTable.AND
        || this == SqlStdOperatorTable.OR)
        && count > 2) {
      return true;
    }
    return litmus.fail("wrong operand count {} for {}", count, this);
  }
  return litmus.succeed();
}
 
Example 5
Source File: RexUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
static SqlOperator op(SqlKind kind) {
    switch (kind) {
    case IS_FALSE:
        return SqlStdOperatorTable.IS_FALSE;
    case IS_TRUE:
        return SqlStdOperatorTable.IS_TRUE;
    case IS_UNKNOWN:
        return SqlStdOperatorTable.IS_UNKNOWN;
    case IS_NULL:
        return SqlStdOperatorTable.IS_NULL;
    case IS_NOT_FALSE:
        return SqlStdOperatorTable.IS_NOT_FALSE;
    case IS_NOT_TRUE:
        return SqlStdOperatorTable.IS_NOT_TRUE;
    case IS_NOT_NULL:
        return SqlStdOperatorTable.IS_NOT_NULL;
    case IS_DISTINCT_FROM:
        return SqlStdOperatorTable.IS_DISTINCT_FROM;
    case IS_NOT_DISTINCT_FROM:
        return SqlStdOperatorTable.IS_NOT_DISTINCT_FROM;
    case EQUALS:
        return SqlStdOperatorTable.EQUALS;
    case NOT_EQUALS:
        return SqlStdOperatorTable.NOT_EQUALS;
    case LESS_THAN:
        return SqlStdOperatorTable.LESS_THAN;
    case GREATER_THAN:
        return SqlStdOperatorTable.GREATER_THAN;
    case LESS_THAN_OR_EQUAL:
        return SqlStdOperatorTable.LESS_THAN_OR_EQUAL;
    case GREATER_THAN_OR_EQUAL:
        return SqlStdOperatorTable.GREATER_THAN_OR_EQUAL;
    case AND:
        return SqlStdOperatorTable.AND;
    case OR:
        return SqlStdOperatorTable.OR;
    case COALESCE:
        return SqlStdOperatorTable.COALESCE;
    default:
        throw new AssertionError(kind);
    }
}
 
Example 6
Source File: RexUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
static SqlOperator op(SqlKind kind) {
  switch (kind) {
  case IS_FALSE:
    return SqlStdOperatorTable.IS_FALSE;
  case IS_TRUE:
    return SqlStdOperatorTable.IS_TRUE;
  case IS_UNKNOWN:
    return SqlStdOperatorTable.IS_UNKNOWN;
  case IS_NULL:
    return SqlStdOperatorTable.IS_NULL;
  case IS_NOT_FALSE:
    return SqlStdOperatorTable.IS_NOT_FALSE;
  case IS_NOT_TRUE:
    return SqlStdOperatorTable.IS_NOT_TRUE;
  case IS_NOT_NULL:
    return SqlStdOperatorTable.IS_NOT_NULL;
  case IS_DISTINCT_FROM:
    return SqlStdOperatorTable.IS_DISTINCT_FROM;
  case IS_NOT_DISTINCT_FROM:
    return SqlStdOperatorTable.IS_NOT_DISTINCT_FROM;
  case EQUALS:
    return SqlStdOperatorTable.EQUALS;
  case NOT_EQUALS:
    return SqlStdOperatorTable.NOT_EQUALS;
  case LESS_THAN:
    return SqlStdOperatorTable.LESS_THAN;
  case GREATER_THAN:
    return SqlStdOperatorTable.GREATER_THAN;
  case LESS_THAN_OR_EQUAL:
    return SqlStdOperatorTable.LESS_THAN_OR_EQUAL;
  case GREATER_THAN_OR_EQUAL:
    return SqlStdOperatorTable.GREATER_THAN_OR_EQUAL;
  case AND:
    return SqlStdOperatorTable.AND;
  case OR:
    return SqlStdOperatorTable.OR;
  case COALESCE:
    return SqlStdOperatorTable.COALESCE;
  default:
    throw new AssertionError(kind);
  }
}