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


Java RexCall.getKind方法代码示例

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


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

示例1: checkForIncompatibleDateTimeOperands

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
 * If one operand in a binary operator is a DateTime type, but the other isn't, we should not push down the predicate
 * @param call
 */
public static void checkForIncompatibleDateTimeOperands(RexCall call) {
  RelDataType op1 = call.getOperands().get(0).getType();
  RelDataType op2 = call.getOperands().get(1).getType();
  if (
      (SqlTypeFamily.DATETIME.contains(op1) && !SqlTypeFamily.DATETIME.contains(op2)) ||
      (SqlTypeFamily.DATETIME.contains(op2) && !SqlTypeFamily.DATETIME.contains(op1)) ||
      (SqlTypeFamily.DATE.contains(op1) && !SqlTypeFamily.DATE.contains(op2)) ||
      (SqlTypeFamily.DATE.contains(op2) && !SqlTypeFamily.DATE.contains(op1)) ||
      (SqlTypeFamily.TIMESTAMP.contains(op1) && !SqlTypeFamily.TIMESTAMP.contains(op2)) ||
      (SqlTypeFamily.TIMESTAMP.contains(op2) && !SqlTypeFamily.TIMESTAMP.contains(op1)) ||
      (SqlTypeFamily.TIME.contains(op1) && !SqlTypeFamily.TIME.contains(op2)) ||
      (SqlTypeFamily.TIME.contains(op2) && !SqlTypeFamily.TIME.contains(op1)))
  {
    throw new PredicateAnalyzerException("Cannot handle " + call.getKind() + " expression for _id field, " + call);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:PredicateAnalyzer.java

示例2: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override public Object visitCall(RexCall call) {
  switch (call.getKind()) {
  case EXTRACT:
    final RexLiteral operand = (RexLiteral) call.getOperands().get(0);
    timeUnits.add((TimeUnitRange) operand.getValue());
    break;
  case FLOOR:
  case CEIL:
    // Check that the call to FLOOR/CEIL is on date-time
    if (call.getOperands().size() == 2) {
      opKinds.add(call.getKind());
    }
    break;
  }
  return super.visitCall(call);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:DateRangeRules.java

示例3: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override public String visitCall(RexCall call) {
  final String name = isItem(call);
  if (name != null) {
    return "\"" + name + "\"";
  }

  final List<String> strings = visitList(call.operands);
  if (call.getKind() == SqlKind.CAST) {
    return strings.get(0).startsWith("$") ? strings.get(0).substring(1) : strings.get(0);
  }
  if (call.getOperator() == SqlStdOperatorTable.ITEM) {
    final RexNode op1 = call.getOperands().get(1);
    if (op1 instanceof RexLiteral && op1.getType().getSqlTypeName() == SqlTypeName.INTEGER) {
      return stripQuotes(strings.get(0)) + "[" + ((RexLiteral) op1).getValue2() + "]";
    }
  }
  throw new IllegalArgumentException("Translation of " + call.toString()
    + "is not supported by ElasticsearchProject");
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:ElasticsearchRules.java

示例4: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override
public Expression visitCall(RexCall call) {

  SqlSyntax syntax = call.getOperator().getSyntax();
  if (!supportedRexCall(call)) {
    throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
  }

  switch (syntax) {
    case BINARY:
      return binary(call);
    case POSTFIX:
      return postfix(call);
    case SPECIAL:
      switch (call.getKind()) {
        case CAST:
          return cast(call);
        case LIKE:
          SqlLikeOperator likeOperator = (SqlLikeOperator) call.getOperator();
          if (!likeOperator.isNegated()) {
            return binary(call);
          }
          throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
        default:
          throw new PredicateAnalyzerException(format("Unsupported call: [%s]", call));
      }
    case FUNCTION:
      if (call.getOperator().getName().equalsIgnoreCase("CONTAINS")) {
        List<Expression> operands = Lists.newArrayList();
        for (RexNode node : call.getOperands()) {
          final Expression nodeExpr = node.accept(this);
          operands.add(nodeExpr);
        }
        String query = convertQueryString(operands.subList(0, operands.size() - 1), operands.get(operands.size() - 1));
        return QueryExpression.create(new NamedFieldExpression(null)).queryString(query);
      }
    default:
      throw new PredicateAnalyzerException(format("Unsupported syntax [%s] for call: [%s]", syntax, call));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:41,代码来源:PredicateAnalyzer.java

示例5: postfix

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private QueryExpression postfix(RexCall call) {
  Preconditions.checkArgument(call.getKind() == SqlKind.IS_NULL || call.getKind() == SqlKind.IS_NOT_NULL);
  if (call.getOperands().size() != 1) {
    throw new PredicateAnalyzerException(format("Unsupported operator: [%s]", call));
  }
  Expression a = call.getOperands().get(0).accept(this);
  // Elasticsearch does not want is null/is not null (exists query) for _id and _index, although it supports for all other metadata column
  isColumn(a, call, ElasticsearchConstants.ID, true);
  isColumn(a, call, ElasticsearchConstants.INDEX, true);
  QueryExpression operand = QueryExpression.create((TerminalExpression)a);
  return call.getKind() == SqlKind.IS_NOT_NULL ? operand.exists() : operand.notExists();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:PredicateAnalyzer.java

示例6: andOr

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private QueryExpression andOr(RexCall call) {
  QueryExpression[] expressions = new QueryExpression[call.getOperands().size()];
  PredicateAnalyzerException firstError = null;
  boolean partial = false;
  for (int i = 0; i < call.getOperands().size(); i++) {
    try {
      expressions[i] = (QueryExpression) call.getOperands().get(i).accept(this);
      partial |= expressions[i].isPartial();
    } catch (PredicateAnalyzerException e) {
      if (firstError == null) {
        firstError = e;
      }
      partial = true;
    }
  }

  switch (call.getKind()) {
    case OR:
      if (partial) {
        if (firstError != null) {
          throw firstError;
        } else {
          throw new PredicateAnalyzerException(format("Unable to handle call: [%s]", call));
        }
      }
      return CompoundQueryExpression.or(expressions);
    case AND:
      return CompoundQueryExpression.and(partial, expressions);
    default:
      throw new PredicateAnalyzerException(format("Unable to handle call: [%s]", call));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:33,代码来源:PredicateAnalyzer.java

示例7: getCompareResultType

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
CompareResultType getCompareResultType(RexCall whenCall) {
    List<RexNode> operands = whenCall.getOperands();
    if (SqlKind.EQUALS == whenCall.getKind() && operands != null && operands.size() == 2) {
        if (operands.get(0).equals(operands.get(1))) {
            return CompareResultType.AlwaysTrue;
        }

        if (isConstant(operands.get(0)) && isConstant(operands.get(1))) {
            return CompareResultType.AlwaysFalse;
        }
    }
    return CompareResultType.Unknown;
}
 
开发者ID:apache,项目名称:kylin,代码行数:14,代码来源:OLAPProjectRel.java

示例8: supportedRexCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private boolean supportedRexCall(RexCall call) {
  final SqlSyntax syntax = call.getOperator().getSyntax();
  switch (syntax) {
    case BINARY:
      switch (call.getKind()) {
        case AND:
        case OR:
        case LIKE:
        case EQUALS:
        case NOT_EQUALS:
        case GREATER_THAN:
        case GREATER_THAN_OR_EQUAL:
        case LESS_THAN:
        case LESS_THAN_OR_EQUAL:
          return true;
        default:
          return false;
      }
    case SPECIAL:
      switch (call.getKind()) {
        case CAST:
        case LIKE:
        case OTHER_FUNCTION:
          return true;
        case CASE:
        case SIMILAR:
        default:
          return false;
      }
    case FUNCTION:
      return true;
    case POSTFIX:
      switch (call.getKind()) {
        case IS_NOT_NULL:
        case IS_NULL:
          return true;
        default: // fall through
      }
    case FUNCTION_ID:
    case FUNCTION_STAR:
    case PREFIX: // NOT()
    default:
      return false;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:46,代码来源:PredicateAnalyzer.java

示例9: binary

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
 * 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,代码行数:73,代码来源:PredicateAnalyzer.java

示例10: leafToRanges

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
protected static List<Range<TimestampString>> leafToRanges(RexCall call,
    TimeZone timeZone, boolean withNot) {
  switch (call.getKind()) {
  case EQUALS:
  case LESS_THAN:
  case LESS_THAN_OR_EQUAL:
  case GREATER_THAN:
  case GREATER_THAN_OR_EQUAL:
  {
    final TimestampString value;
    if (call.getOperands().get(0) instanceof RexInputRef
        && literalValue(call.getOperands().get(1), timeZone) != null) {
      value = literalValue(call.getOperands().get(1), timeZone);
    } else if (call.getOperands().get(1) instanceof RexInputRef
        && literalValue(call.getOperands().get(0), timeZone) != null) {
      value = literalValue(call.getOperands().get(0), timeZone);
    } else {
      return null;
    }
    switch (call.getKind()) {
    case LESS_THAN:
      return ImmutableList.of(withNot ? Range.atLeast(value) : Range.lessThan(value));
    case LESS_THAN_OR_EQUAL:
      return ImmutableList.of(withNot ? Range.greaterThan(value) : Range.atMost(value));
    case GREATER_THAN:
      return ImmutableList.of(withNot ? Range.atMost(value) : Range.greaterThan(value));
    case GREATER_THAN_OR_EQUAL:
      return ImmutableList.of(withNot ? Range.lessThan(value) : Range.atLeast(value));
    default:
      if (!withNot) {
        return ImmutableList.of(Range.closed(value, value));
      }
      return ImmutableList.of(Range.lessThan(value), Range.greaterThan(value));
    }
  }
  case BETWEEN:
  {
    final TimestampString value1;
    final TimestampString value2;
    if (literalValue(call.getOperands().get(2), timeZone) != null
        && literalValue(call.getOperands().get(3), timeZone) != null) {
      value1 = literalValue(call.getOperands().get(2), timeZone);
      value2 = literalValue(call.getOperands().get(3), timeZone);
    } else {
      return null;
    }

    boolean inverted = value1.compareTo(value2) > 0;
    if (!withNot) {
      return ImmutableList.of(
          inverted ? Range.closed(value2, value1) : Range.closed(value1, value2));
    }
    return ImmutableList.of(Range.lessThan(inverted ? value2 : value1),
        Range.greaterThan(inverted ? value1 : value2));
  }
  case IN:
  {
    ImmutableList.Builder<Range<TimestampString>> ranges =
        ImmutableList.builder();
    for (RexNode operand : Util.skip(call.operands)) {
      final TimestampString element = literalValue(operand, timeZone);
      if (element == null) {
        return null;
      }
      if (withNot) {
        ranges.add(Range.lessThan(element));
        ranges.add(Range.greaterThan(element));
      } else {
        ranges.add(Range.closed(element, element));
      }
    }
    return ranges.build();
  }
  default:
    return null;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:78,代码来源:DruidDateTimeUtils.java

示例11: visitCall

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
@Override public String visitCall(RexCall call) {
  String name = isItem(call);
  if (name != null) {
    return "'$" + name + "'";
  }
  final List<String> strings = visitList(call.operands);
  if (call.getKind() == SqlKind.CAST) {
    return strings.get(0);
  }
  String stdOperator = MONGO_OPERATORS.get(call.getOperator());
  if (stdOperator != null) {
    return "{" + stdOperator + ": [" + Util.commaList(strings) + "]}";
  }
  if (call.getOperator() == SqlStdOperatorTable.ITEM) {
    final RexNode op1 = call.operands.get(1);
    if (op1 instanceof RexLiteral
        && op1.getType().getSqlTypeName() == SqlTypeName.INTEGER) {
      if (!Bug.CALCITE_194_FIXED) {
        return "'" + stripQuotes(strings.get(0)) + "["
            + ((RexLiteral) op1).getValue2() + "]'";
      }
      return strings.get(0) + "[" + strings.get(1) + "]";
    }
  }
  if (call.getOperator() == SqlStdOperatorTable.CASE) {
    StringBuilder sb = new StringBuilder();
    StringBuilder finish = new StringBuilder();
    // case(a, b, c)  -> $cond:[a, b, c]
    // case(a, b, c, d) -> $cond:[a, b, $cond:[c, d, null]]
    // case(a, b, c, d, e) -> $cond:[a, b, $cond:[c, d, e]]
    for (int i = 0; i < strings.size(); i += 2) {
      sb.append("{$cond:[");
      finish.append("]}");

      sb.append(strings.get(i));
      sb.append(',');
      sb.append(strings.get(i + 1));
      sb.append(',');
      if (i == strings.size() - 3) {
        sb.append(strings.get(i + 2));
        break;
      }
      if (i == strings.size() - 2) {
        sb.append("null");
        break;
      }
    }
    sb.append(finish);
    return sb.toString();
  }
  throw new IllegalArgumentException("Translation of " + call.toString()
      + " is not supported by MongoProject");
}
 
开发者ID:apache,项目名称:calcite,代码行数:54,代码来源:MongoRules.java

示例12: pushPredicateIntoCase

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/** Pushes predicates into a CASE.
 *
 * <p>We have a loose definition of 'predicate': any boolean expression will
 * do, except CASE. For example '(CASE ...) = 5' or '(CASE ...) IS NULL'.
 */
public static RexCall pushPredicateIntoCase(RexCall call) {
  if (call.getType().getSqlTypeName() != SqlTypeName.BOOLEAN) {
    return call;
  }
  switch (call.getKind()) {
  case CASE:
  case AND:
  case OR:
    return call; // don't push CASE into CASE!
  case EQUALS: {
    // checks that the EQUALS operands may be splitted and
    // doesn't push EQUALS into CASE
    List<RexNode> equalsOperands = call.getOperands();
    ImmutableBitSet left = RelOptUtil.InputFinder.bits(equalsOperands.get(0));
    ImmutableBitSet right = RelOptUtil.InputFinder.bits(equalsOperands.get(1));
    if (!left.isEmpty() && !right.isEmpty() && left.intersect(right).isEmpty()) {
      return call;
    }
  }
  }
  int caseOrdinal = -1;
  final List<RexNode> operands = call.getOperands();
  for (int i = 0; i < operands.size(); i++) {
    RexNode operand = operands.get(i);
    switch (operand.getKind()) {
    case CASE:
      caseOrdinal = i;
    }
  }
  if (caseOrdinal < 0) {
    return call;
  }
  // Convert
  //   f(CASE WHEN p1 THEN v1 ... END, arg)
  // to
  //   CASE WHEN p1 THEN f(v1, arg) ... END
  final RexCall case_ = (RexCall) operands.get(caseOrdinal);
  final List<RexNode> nodes = new ArrayList<>();
  for (int i = 0; i < case_.getOperands().size(); i++) {
    RexNode node = case_.getOperands().get(i);
    if (!RexUtil.isCasePredicate(case_, i)) {
      node = substitute(call, caseOrdinal, node);
    }
    nodes.add(node);
  }
  return case_.clone(call.getType(), nodes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:53,代码来源:ReduceExpressionsRule.java

示例13: splitJoinCondition

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
private static void splitJoinCondition(
    final RexBuilder rexBuilder,
    final int leftFieldCount,
    RexNode condition,
    List<Integer> leftKeys,
    List<Integer> rightKeys,
    List<Boolean> filterNulls,
    List<RexNode> nonEquiList) {
  if (condition instanceof RexCall) {
    RexCall call = (RexCall) condition;
    SqlKind kind = call.getKind();
    if (kind == SqlKind.AND) {
      for (RexNode operand : call.getOperands()) {
        splitJoinCondition(
            rexBuilder,
            leftFieldCount,
            operand,
            leftKeys,
            rightKeys,
            filterNulls,
            nonEquiList);
      }
      return;
    }

    if (filterNulls != null) {
      call = collapseExpandedIsNotDistinctFromExpr(call, rexBuilder);
      kind = call.getKind();
    }

    // "=" and "IS NOT DISTINCT FROM" are the same except for how they
    // treat nulls.
    if (kind == SqlKind.EQUALS
        || (filterNulls != null && kind == SqlKind.IS_NOT_DISTINCT_FROM)) {
      final List<RexNode> operands = call.getOperands();
      if ((operands.get(0) instanceof RexInputRef)
          && (operands.get(1) instanceof RexInputRef)) {
        RexInputRef op0 = (RexInputRef) operands.get(0);
        RexInputRef op1 = (RexInputRef) operands.get(1);

        RexInputRef leftField;
        RexInputRef rightField;
        if ((op0.getIndex() < leftFieldCount)
            && (op1.getIndex() >= leftFieldCount)) {
          // Arguments were of form 'op0 = op1'
          leftField = op0;
          rightField = op1;
        } else if (
            (op1.getIndex() < leftFieldCount)
                && (op0.getIndex() >= leftFieldCount)) {
          // Arguments were of form 'op1 = op0'
          leftField = op1;
          rightField = op0;
        } else {
          nonEquiList.add(condition);
          return;
        }

        leftKeys.add(leftField.getIndex());
        rightKeys.add(rightField.getIndex() - leftFieldCount);
        if (filterNulls != null) {
          filterNulls.add(kind == SqlKind.EQUALS);
        }
        return;
      }
      // Arguments were not field references, one from each side, so
      // we fail. Fall through.
    }
  }

  // Add this condition to the list of non-equi-join conditions.
  if (!condition.isAlwaysTrue()) {
    nonEquiList.add(condition);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:76,代码来源:RelOptUtil.java

示例14: collapseExpandedIsNotDistinctFromExpr

import org.apache.calcite.rex.RexCall; //导入方法依赖的package包/类
/**
 * 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,代码行数:73,代码来源:RelOptUtil.java


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