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


Java SqlKind.IS_NOT_DISTINCT_FROM属性代码示例

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


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

示例1: buildJoinConditions

/**
 * Build the list of join conditions for this join.
 * A join condition is built only for equality and IS NOT DISTINCT FROM comparisons. The difference is:
 * null == null is FALSE whereas null IS NOT DISTINCT FROM null is TRUE
 * For a use case of the IS NOT DISTINCT FROM comparison, see
 * {@link org.apache.calcite.rel.rules.RemoveDistinctAggregateRule}
 * @param conditions populated list of join conditions
 * @param leftFields join fields from the left input
 * @param rightFields join fields from the right input
 */
protected void buildJoinConditions(List<JoinCondition> conditions,
    List<String> leftFields,
    List<String> rightFields,
    List<Integer> leftKeys,
    List<Integer> rightKeys) {
  List<RexNode> conjuncts = RelOptUtil.conjunctions(this.getCondition());
  short i=0;

  for (Pair<Integer, Integer> pair : Pair.zip(leftKeys, rightKeys)) {
    final RexNode conditionExpr = conjuncts.get(i++);
    final SqlKind kind  = conditionExpr.getKind();
    if (kind != SqlKind.EQUALS && kind != SqlKind.IS_NOT_DISTINCT_FROM) {
      throw UserException.unsupportedError()
          .message("Unsupported comparator in join condition %s", conditionExpr)
          .build(logger);
    }

    conditions.add(new JoinCondition(kind.toString(),
        FieldReference.getWithQuotedRef(leftFields.get(pair.left)),
        FieldReference.getWithQuotedRef(rightFields.get(pair.right))));
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:JoinPrel.java

示例2: buildJoinConditions

/**
 * Build the list of join conditions for this join.
 * A join condition is built only for equality and IS NOT DISTINCT FROM comparisons. The difference is:
 * null == null is FALSE whereas null IS NOT DISTINCT FROM null is TRUE
 * For a use case of the IS NOT DISTINCT FROM comparison, see
 * {@link org.apache.calcite.rel.rules.RemoveDistinctAggregateRule}
 * @param conditions populated list of join conditions
 * @param leftFields join fields from the left input
 * @param rightFields join fields from the right input
 */
protected void buildJoinConditions(List<JoinCondition> conditions,
    List<String> leftFields,
    List<String> rightFields,
    List<Integer> leftKeys,
    List<Integer> rightKeys) {
  List<RexNode> conjuncts = RelOptUtil.conjunctions(this.getCondition());
  short i=0;

  RexNode comp1 = null, comp2 = null;
  for (Pair<Integer, Integer> pair : Pair.zip(leftKeys, rightKeys)) {
    if (comp1 == null) {
      comp1 = conjuncts.get(i++);
      if ( ! (comp1.getKind() == SqlKind.EQUALS || comp1.getKind() == SqlKind.IS_NOT_DISTINCT_FROM)) {
        throw new IllegalArgumentException("This type of join only supports '=' and 'is not distinct from' comparators.");
      }
    } else {
      comp2 = conjuncts.get(i++);
      if (comp1.getKind() != comp2.getKind()) {
        // it does not seem necessary at this time to support join conditions which have mixed comparators - e.g
        // 'a1 = a2 AND b1 IS NOT DISTINCT FROM b2'
        String msg = String.format("This type of join does not support mixed comparators: '%s' and '%s'.", comp1, comp2);
        throw new IllegalArgumentException(msg);
      }

    }
    conditions.add(new JoinCondition(comp1.getKind().toString(), FieldReference.getWithQuotedRef(leftFields.get(pair.left)),
        FieldReference.getWithQuotedRef(rightFields.get(pair.right))));
  }

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:40,代码来源:JoinPrel.java

示例3: splitJoinCondition

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,代码行数:75,代码来源:RelOptUtil.java


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