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


Java SqlStdOperatorTable.EQUALS属性代码示例

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


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

示例1: evaluate

/**
 * Evaluates a {@link NumericHaving}.
 *
 * @param having  The NumericHaving filter to be evaluated.
 * @param builder  The RelBuilder used with Calcite to make queries.
 * @param apiToFieldMapper  A function to get the aliased aggregation's name from the metric name.
 *
 * @return the equivalent {@link RexNode} to be used in a sql query.
 */
public RexNode evaluate(NumericHaving having, RelBuilder builder, ApiToFieldMapper apiToFieldMapper) {
    Having.DefaultHavingType havingType = (Having.DefaultHavingType) having.getType();
    SqlOperator operator = null;
    switch (havingType) {
        case EQUAL_TO:
            operator = SqlStdOperatorTable.EQUALS;
            break;
        case LESS_THAN:
            operator = SqlStdOperatorTable.LESS_THAN;
            break;
        case GREATER_THAN:
            operator = SqlStdOperatorTable.GREATER_THAN;
            break;
    }
    return builder.call(
            operator,
            builder.field(apiToFieldMapper.apply(having.getAggregation())),
            builder.literal(having.getValue())
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:29,代码来源:HavingEvaluator.java

示例2: op

public static SqlOperator op(SqlKind kind, SqlOperator operator) {
  switch (kind) {
  case EQUALS:
    return SqlStdOperatorTable.EQUALS;
  case NOT_EQUALS:
    return SqlStdOperatorTable.NOT_EQUALS;
  case GREATER_THAN:
    return SqlStdOperatorTable.GREATER_THAN;
  case GREATER_THAN_OR_EQUAL:
    return SqlStdOperatorTable.GREATER_THAN_OR_EQUAL;
  case LESS_THAN:
    return SqlStdOperatorTable.LESS_THAN;
  case LESS_THAN_OR_EQUAL:
    return SqlStdOperatorTable.LESS_THAN_OR_EQUAL;
  case IS_DISTINCT_FROM:
    return SqlStdOperatorTable.IS_DISTINCT_FROM;
  case IS_NOT_DISTINCT_FROM:
    return SqlStdOperatorTable.IS_NOT_DISTINCT_FROM;
  default:
    return operator;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelOptUtil.java

示例3: getFilter

private static Integer getFilter(boolean cooperative, List<RexNode> filters) {
  final Iterator<RexNode> filterIter = filters.iterator();
  while (filterIter.hasNext()) {
    final RexNode node = filterIter.next();
    if (cooperative
        && node instanceof RexCall
        && ((RexCall) node).getOperator() == SqlStdOperatorTable.EQUALS
        && ((RexCall) node).getOperands().get(0) instanceof RexInputRef
        && ((RexInputRef) ((RexCall) node).getOperands().get(0)).getIndex()
        == 0
        && ((RexCall) node).getOperands().get(1) instanceof RexLiteral) {
      final RexNode op1 = ((RexCall) node).getOperands().get(1);
      filterIter.remove();
      return ((BigDecimal) ((RexLiteral) op1).getValue()).intValue();
    }
  }
  return null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:ScannableTableTest.java

示例4: isDistinctFromInternal

private static RexNode isDistinctFromInternal(
    RexBuilder rexBuilder,
    RexNode x,
    RexNode y,
    boolean neg) {
  SqlOperator nullOp;
  SqlOperator eqOp;
  if (neg) {
    nullOp = SqlStdOperatorTable.IS_NULL;
    eqOp = SqlStdOperatorTable.EQUALS;
  } else {
    nullOp = SqlStdOperatorTable.IS_NOT_NULL;
    eqOp = SqlStdOperatorTable.NOT_EQUALS;
  }
  // By the time the ELSE is reached, x and y are known to be not null;
  // therefore the whole CASE is not null.
  RexNode[] whenThenElse = {
      // when x is null
      rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL, x),

      // then return y is [not] null
      rexBuilder.makeCall(nullOp, y),

      // when y is null
      rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL, y),

      // then return x is [not] null
      rexBuilder.makeCall(nullOp, x),

      // else return x compared to y
      rexBuilder.makeCall(eqOp,
          rexBuilder.makeNotNull(x),
          rexBuilder.makeNotNull(y))
  };
  return rexBuilder.makeCall(
      SqlStdOperatorTable.CASE,
      whenThenElse);
}
 
开发者ID:apache,项目名称:calcite,代码行数:38,代码来源:RelOptUtil.java

示例5: op

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 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;
  default:
    throw new AssertionError(kind);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:RexUtil.java

示例6: getPredicates

/**
 * Infers predicates for a project.
 *
 * <ol>
 * <li>create a mapping from input to projection. Map only positions that
 * directly reference an input column.
 * <li>Expressions that only contain above columns are retained in the
 * Project's pullExpressions list.
 * <li>For e.g. expression 'a + e = 9' below will not be pulled up because 'e'
 * is not in the projection list.
 *
 * <blockquote><pre>
 * inputPullUpExprs:      {a &gt; 7, b + c &lt; 10, a + e = 9}
 * projectionExprs:       {a, b, c, e / 2}
 * projectionPullupExprs: {a &gt; 7, b + c &lt; 10}
 * </pre></blockquote>
 *
 * </ol>
 */
public RelOptPredicateList getPredicates(Project project,
    RelMetadataQuery mq) {
  final RelNode input = project.getInput();
  final RexBuilder rexBuilder = project.getCluster().getRexBuilder();
  final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
  final List<RexNode> projectPullUpPredicates = new ArrayList<>();

  ImmutableBitSet.Builder columnsMappedBuilder = ImmutableBitSet.builder();
  Mapping m = Mappings.create(MappingType.PARTIAL_FUNCTION,
      input.getRowType().getFieldCount(),
      project.getRowType().getFieldCount());

  for (Ord<RexNode> o : Ord.zip(project.getProjects())) {
    if (o.e instanceof RexInputRef) {
      int sIdx = ((RexInputRef) o.e).getIndex();
      m.set(sIdx, o.i);
      columnsMappedBuilder.set(sIdx);
    }
  }

  // Go over childPullUpPredicates. If a predicate only contains columns in
  // 'columnsMapped' construct a new predicate based on mapping.
  final ImmutableBitSet columnsMapped = columnsMappedBuilder.build();
  for (RexNode r : inputInfo.pulledUpPredicates) {
    RexNode r2 = projectPredicate(rexBuilder, input, r, columnsMapped);
    if (!r2.isAlwaysTrue()) {
      r2 = r2.accept(new RexPermuteInputsShuttle(m, input));
      projectPullUpPredicates.add(r2);
    }
  }

  // Project can also generate constants. We need to include them.
  for (Ord<RexNode> expr : Ord.zip(project.getProjects())) {
    if (RexLiteral.isNullLiteral(expr.e)) {
      projectPullUpPredicates.add(
          rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
              rexBuilder.makeInputRef(project, expr.i)));
    } else if (RexUtil.isConstant(expr.e)) {
      final List<RexNode> args =
          ImmutableList.of(rexBuilder.makeInputRef(project, expr.i), expr.e);
      final SqlOperator op = args.get(0).getType().isNullable()
          || args.get(1).getType().isNullable()
          ? SqlStdOperatorTable.IS_NOT_DISTINCT_FROM
          : SqlStdOperatorTable.EQUALS;
      projectPullUpPredicates.add(rexBuilder.makeCall(op, args));
    }
  }
  return RelOptPredicateList.of(rexBuilder, projectPullUpPredicates);
}
 
开发者ID:apache,项目名称:calcite,代码行数:68,代码来源:RelMdPredicates.java

示例7: flattenComparison

private RexNode flattenComparison(
    RexBuilder rexBuilder,
    SqlOperator op,
    List<RexNode> exprs) {
  final List<Pair<RexNode, String>> flattenedExps = Lists.newArrayList();
  flattenProjections(this, exprs, null, "", flattenedExps);
  int n = flattenedExps.size() / 2;
  boolean negate = false;
  if (op.getKind() == SqlKind.NOT_EQUALS) {
    negate = true;
    op = SqlStdOperatorTable.EQUALS;
  }
  if ((n > 1) && op.getKind() != SqlKind.EQUALS) {
    throw Util.needToImplement(
        "inequality comparison for row types");
  }
  RexNode conjunction = null;
  for (int i = 0; i < n; ++i) {
    RexNode comparison =
        rexBuilder.makeCall(
            op,
            flattenedExps.get(i).left,
            flattenedExps.get(i + n).left);
    if (conjunction == null) {
      conjunction = comparison;
    } else {
      conjunction =
          rexBuilder.makeCall(
              SqlStdOperatorTable.AND,
              conjunction,
              comparison);
    }
  }
  if (negate) {
    return rexBuilder.makeCall(
        SqlStdOperatorTable.NOT,
        conjunction);
  } else {
    return conjunction;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:41,代码来源:RelStructuredTypeFlattener.java


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