当前位置: 首页>>代码示例>>Java>>正文


Java SqlKind.OR属性代码示例

本文整理汇总了Java中org.apache.calcite.sql.SqlKind.OR属性的典型用法代码示例。如果您正苦于以下问题:Java SqlKind.OR属性的具体用法?Java SqlKind.OR怎么用?Java SqlKind.OR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.calcite.sql.SqlKind的用法示例。


在下文中一共展示了SqlKind.OR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitCall

@Override
public RexNode visitCall(RexCall call) {
  SqlOperator op = call.getOperator();
  SqlKind kind = op.getKind();
  RelDataType type = call.getType();
  if (kind == SqlKind.OR || kind == SqlKind.AND) {
    if (call.getOperands().size() > 2) {
      List<RexNode> children = new ArrayList(call.getOperands());
      RexNode left = children.remove(0).accept(this);
      RexNode right = builder.makeCall(type, op, children).accept(this);
      return builder.makeCall(type, op, ImmutableList.of(left, right));
    }
  }
  return builder.makeCall(type, op, visitChildren(call));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:RewriteAsBinaryOperators.java

示例2: visitCall

@Override
public RexNode visitCall(RexCall call) {
  SqlOperator op = call.getOperator();
  SqlKind kind = op.getKind();
  RelDataType type = call.getType();
  if (kind == SqlKind.OR || kind == SqlKind.AND) {
    if (call.getOperands().size() > 2) {
      List<RexNode> children = new ArrayList<>(call.getOperands());
      RexNode left = children.remove(0).accept(this);
      RexNode right = builder.makeCall(type, op, children).accept(this);
      return builder.makeCall(type, op, ImmutableList.of(left, right));
    }
  }
  return builder.makeCall(type, op, visitChildren(call));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:RewriteAsBinaryOperators.java

示例3: binary

/**
 * Process a call which is a binary operation, transforming into an equivalent
 * query expression. Note that the incoming call may be either a simple binary
 * expression, such as 'foo > 5', or it may be several simple expressions connected
 * by 'AND' or 'OR' operators, such as 'foo > 5 AND bar = 'abc' AND 'rot' < 1'.
 */
private QueryExpression binary(RexCall call) {

  // if AND/OR, do special handling
  if (call.getKind() == SqlKind.AND || call.getKind() == SqlKind.OR) {
    return andOr(call);
  }

  checkForIncompatibleDateTimeOperands(call);

  Preconditions.checkState(call.getOperands().size() == 2);
  final Expression a = call.getOperands().get(0).accept(this);
  final Expression b = call.getOperands().get(1).accept(this);

  final SwapResult pair = swap(a, b);
  final boolean swapped = pair.isSwapped();

  // For _id and _index columns, only equals/not_equals work!
  if (isColumn(pair.getKey(), call, ElasticsearchConstants.ID, false)
    || isColumn(pair.getKey(), call, ElasticsearchConstants.INDEX, false)
    || isColumn(pair.getKey(), call, ElasticsearchConstants.UID, false)) {
    switch (call.getKind()) {
      case EQUALS:
      case NOT_EQUALS:
        break;
      default:
        throw new PredicateAnalyzerException("Cannot handle " + call.getKind() + " expression for _id field, " + call);
    }
  }

  switch (call.getKind()) {
    case LIKE:
      // LIKE/regexp cannot handle metadata columns
      isMeta(pair.getKey(), call, true);
      String sqlRegex = RegexpUtil.sqlToRegexLike(pair.getValue().stringValue());
      RexLiteral sqlRegexLiteral = rexBuilder.makeLiteral(sqlRegex);
      LiteralExpression sqlRegexExpression = new LiteralExpression(sqlRegexLiteral);
      return QueryExpression.create(pair.getKey()).like(sqlRegexExpression);
    case EQUALS:
      return QueryExpression.create(pair.getKey()).equals(pair.getValue());
    case NOT_EQUALS:
      return QueryExpression.create(pair.getKey()).notEquals(pair.getValue());
    case GREATER_THAN:
      if (swapped) {
        return QueryExpression.create(pair.getKey()).lt(pair.getValue());
      }
      return QueryExpression.create(pair.getKey()).gt(pair.getValue());
    case GREATER_THAN_OR_EQUAL:
      if (swapped) {
        return QueryExpression.create(pair.getKey()).lte(pair.getValue());
      }
      return QueryExpression.create(pair.getKey()).gte(pair.getValue());
    case LESS_THAN:
      if (swapped) {
        return QueryExpression.create(pair.getKey()).gt(pair.getValue());
      }
      return QueryExpression.create(pair.getKey()).lt(pair.getValue());
    case LESS_THAN_OR_EQUAL:
      if (swapped) {
        return QueryExpression.create(pair.getKey()).gte(pair.getValue());
      }
      return QueryExpression.create(pair.getKey()).lte(pair.getValue());
    default:
      break;
  }
  throw new PredicateAnalyzerException(format("Unable to handle call: [%s]", call));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:72,代码来源:PredicateAnalyzer.java

示例4: collapseExpandedIsNotDistinctFromExpr

/**
 * Helper method for
 * {@link #splitJoinCondition(RexBuilder, int, RexNode, List, List, List, List)} and
 * {@link #splitJoinCondition(List, List, RexNode, List, List, List, List)}.
 *
 * <p>If the given expr <code>call</code> is an expanded version of
 * IS NOT DISTINCT FROM function call, collapse it and return a
 * IS NOT DISTINCT FROM function call.
 *
 * <p>For example: {@code t1.key IS NOT DISTINCT FROM t2.key}
 * can rewritten in expanded form as
 * {@code t1.key = t2.key OR (t1.key IS NULL AND t2.key IS NULL)}.
 *
 * @param call       Function expression to try collapsing.
 * @param rexBuilder {@link RexBuilder} instance to create new {@link RexCall} instances.
 * @return If the given function is an expanded IS NOT DISTINCT FROM function call,
 *         return a IS NOT DISTINCT FROM function call. Otherwise return the input
 *         function call as it is.
 */
private static RexCall collapseExpandedIsNotDistinctFromExpr(final RexCall call,
    final RexBuilder rexBuilder) {
  if (call.getKind() != SqlKind.OR || call.getOperands().size() != 2) {
    return call;
  }

  final RexNode op0 = call.getOperands().get(0);
  final RexNode op1 = call.getOperands().get(1);

  if (!(op0 instanceof RexCall) || !(op1 instanceof RexCall)) {
    return call;
  }

  RexCall opEqCall = (RexCall) op0;
  RexCall opNullEqCall = (RexCall) op1;

  if (opEqCall.getKind() == SqlKind.AND
      && opNullEqCall.getKind() == SqlKind.EQUALS) {
    RexCall temp = opEqCall;
    opEqCall = opNullEqCall;
    opNullEqCall = temp;
  }

  if (opNullEqCall.getKind() != SqlKind.AND
      || opNullEqCall.getOperands().size() != 2
      || opEqCall.getKind() != SqlKind.EQUALS) {
    return call;
  }

  final RexNode op10 = opNullEqCall.getOperands().get(0);
  final RexNode op11 = opNullEqCall.getOperands().get(1);
  if (op10.getKind() != SqlKind.IS_NULL
      || op11.getKind() != SqlKind.IS_NULL) {
    return call;
  }
  final RexNode isNullInput0 = ((RexCall) op10).getOperands().get(0);
  final RexNode isNullInput1 = ((RexCall) op11).getOperands().get(0);

  final String isNullInput0Digest = isNullInput0.toString();
  final String isNullInput1Digest = isNullInput1.toString();
  final String equalsInput0Digest = opEqCall.getOperands().get(0).toString();
  final String equalsInput1Digest = opEqCall.getOperands().get(1).toString();

  if ((isNullInput0Digest.equals(equalsInput0Digest)
          && isNullInput1Digest.equals(equalsInput1Digest))
      || (isNullInput1Digest.equals(equalsInput0Digest)
          && isNullInput0Digest.equals(equalsInput1Digest))) {
    return (RexCall) rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
        ImmutableList.of(isNullInput0, isNullInput1));
  }

  return call;
}
 
开发者ID:apache,项目名称:calcite,代码行数:72,代码来源:RelOptUtil.java

示例5: isAssociative

/**
 * Returns whether an operator is associative. AND is associative,
 * which means that "(x AND y) and z" is equivalent to "x AND (y AND z)".
 * We might well flatten the tree, and write "AND(x, y, z)".
 */
private static boolean isAssociative(SqlOperator op) {
  return op.getKind() == SqlKind.AND
      || op.getKind() == SqlKind.OR;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:RexUtil.java


注:本文中的org.apache.calcite.sql.SqlKind.OR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。