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


Java RexNode.getKind方法代码示例

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


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

示例1: buildJoinConditions

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

示例2: canJoinOnCondition

import org.apache.calcite.rex.RexNode; //导入方法依赖的package包/类
/**
 * Returns whether a condition is supported by {@link JdbcJoin}.
 *
 * <p>Corresponds to the capabilities of
 * {@link JdbcJoin#convertConditionToSqlNode}.
 *
 * @param node Condition
 * @return Whether condition is supported
 */
private static boolean canJoinOnCondition(RexNode node) {
  final List<RexNode> operands;
  switch (node.getKind()) {
  case AND:
  case OR:
    operands = ((RexCall) node).getOperands();
    for (RexNode operand : operands) {
      if (!canJoinOnCondition(operand)) {
        return false;
      }
    }
    return true;

  case EQUALS:
  case IS_NOT_DISTINCT_FROM:
  case NOT_EQUALS:
  case GREATER_THAN:
  case GREATER_THAN_OR_EQUAL:
  case LESS_THAN:
  case LESS_THAN_OR_EQUAL:
    operands = ((RexCall) node).getOperands();
    if ((operands.get(0) instanceof RexInputRef)
        && (operands.get(1) instanceof RexInputRef)) {
      return true;
    }
    // fall through

  default:
    return false;
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:41,代码来源:JdbcStoragePlugin.java

示例3: makeCast

import org.apache.calcite.rex.RexNode; //导入方法依赖的package包/类
@Override
public RexNode makeCast(
  RelDataType type,
  RexNode exp,
  boolean matchNullability) {
  // Special case: bypassing Calcite for interval types
  if (!(exp instanceof RexLiteral)
      && SqlTypeUtil.isExactNumeric(type)
      && SqlTypeUtil.isInterval(exp.getType())) {
    return makeAbstractCast(type, exp);
  }
  RexNode castRexNode = super.makeCast(type, exp, matchNullability);

  // If we have a CAST(A, TYPE) and A is already of the same TYPE (including nullability),
  // then return just A.
  if (castRexNode instanceof RexCall
    && castRexNode.getKind() == SqlKind.CAST
    && castRexNode.getType().equals(((RexCall) castRexNode).getOperands().get(0).getType())) {
    return ((RexCall) castRexNode).getOperands().get(0);
  }

  // If the types do not match (especially nullability), then cast it.
  if (!castRexNode.getType().equals(type)) {
    return makeAbstractCast(type, castRexNode);
  }

  return castRexNode;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:29,代码来源:DremioRexBuilder.java

示例4: getRexInputRefIndex

import org.apache.calcite.rex.RexNode; //导入方法依赖的package包/类
private static int getRexInputRefIndex(RexNode operand) {
  if (SqlKind.INPUT_REF != operand.getKind()) {
    return -1;
  }
  return ((RexInputRef)operand).getIndex();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:7,代码来源:JoinExtractor.java

示例5: getJoins

import org.apache.calcite.rex.RexNode; //导入方法依赖的package包/类
public static List<JoinInfo> getJoins(RelNode graph){
  JoinFinder finder = new JoinFinder(graph.getCluster().getMetadataQuery());
  graph.accept(finder);
  List<JoinInfo> definitions = new ArrayList<>();
  joins: for (JoinDefinition joinDefinition : finder.definitions) {
    int degrees = 0; // TODO: implement degrees in extract
    if (joinDefinition.getLeftTables().size() != 1
        || joinDefinition.getRightTables().size() != 1) {
      // this join is not exploitable
      continue;
    }
    List<String> leftTable = joinDefinition.getLeftTables().iterator().next();
    List<String> rightTable = joinDefinition.getRightTables().iterator().next();
    List<JoinConditionInfo> conditions = new ArrayList<>();
    RexNode joinCondition = joinDefinition.getJoinCondition();
    switch (joinCondition.getKind()) {
    // TODO and
    case EQUALS:
      final JoinConditionInfo equalsExtractCond = extractEquals(joinDefinition, (RexCall) joinCondition);
      if (equalsExtractCond == null) {
        continue joins;
      }
      conditions.add(equalsExtractCond);
      break;
    case AND:
      RexCall andCall = (RexCall) joinCondition;
      for (RexNode operand : andCall.getOperands()) {
        if (operand.getKind() == SqlKind.EQUALS) {
          final JoinConditionInfo equalsExtractEquals = extractEquals(joinDefinition, (RexCall) operand);
          if (equalsExtractEquals == null) {
            continue joins;
          }
          conditions.add(equalsExtractEquals);
        } else {
          // this join is not exploitable
          continue joins;
        }
      }
      break;
    default:
      // this join is not exploitable
      continue joins;
    }
    definitions.add(
        new JoinInfo(toJoinType(joinDefinition.getJoinType()), degrees)
        .setLeftTablePathList(leftTable)
        .setRightTablePathList(rightTable)
        .setConditionsList(conditions));
  }
  return definitions;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:52,代码来源:JoinExtractor.java


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