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


Java RexFieldCollation类代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexFieldCollation的典型用法代码示例。如果您正苦于以下问题:Java RexFieldCollation类的具体用法?Java RexFieldCollation怎么用?Java RexFieldCollation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visitOver

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
public Boolean visitOver(RexOver over) {
  if (!visitCall(over)) {
    return false;
  }
  ;

  final RexWindow window = over.getWindow();
  for (RexFieldCollation orderKey : window.orderKeys) {
    if (!((RexNode) orderKey.left).accept(this)) {
      return false;
    }
  }

  for (RexNode partitionKey : window.partitionKeys) {
    if (!partitionKey.accept(this)) {
      return false;
    }
  }

  return true;

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

示例2: toSql

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
private SqlNode toSql(RexProgram program, RexFieldCollation rfc) {
  SqlNode node = toSql(program, rfc.left);
  switch (rfc.getDirection()) {
  case DESCENDING:
  case STRICTLY_DESCENDING:
    node = SqlStdOperatorTable.DESC.createCall(POS, node);
  }
  if (rfc.getNullDirection()
          != dialect.defaultNullDirection(rfc.getDirection())) {
    switch (rfc.getNullDirection()) {
    case FIRST:
      node = SqlStdOperatorTable.NULLS_FIRST.createCall(POS, node);
      break;
    case LAST:
      node = SqlStdOperatorTable.NULLS_LAST.createCall(POS, node);
      break;
    }
  }
  return node;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:SqlImplementor.java

示例3: getCollation

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
public static RelCollation getCollation(
    final List<RexFieldCollation> collations) {
  return RelCollations.of(
      new AbstractList<RelFieldCollation>() {
        public RelFieldCollation get(int index) {
          final RexFieldCollation collation = collations.get(index);
          return new RelFieldCollation(
              ((RexLocalRef) collation.left).getIndex(),
              collation.getDirection(),
              collation.getNullDirection());
        }

        public int size() {
          return collations.size();
        }
      });
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:Window.java

示例4: makeOver

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
public RexNode makeOver(
		SqlAggFunction operator,
		List<RexNode> expressions,
		List<RexNode> partitionKeys
) {
	final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);

	// TODO
	// This is a temporal fix to make HAWQ work with OVER + UNLIMITED BOUNDS
	// HAWQ requires ORDER BY if andy BOUNDS are set even unlimited upper and lower BOUNDS (which is equal to
	// the entire partition - e.g. not setting BOUNDs at all --
	// Note that the unnecessary ORDER BY have negative performance impact and has to be remove once either HAWQ
	// start supporting unbounded bounds without order by or Calcite can generate shorthand OVER PARTITION BY
	// syntax.
	List<RexFieldCollation> orderKeys = expressions.stream().map(
			rexNode -> new RexFieldCollation(rexNode, flags)).collect(Collectors.toList());

	return makeOver(
			operator,
			expressions,
			partitionKeys,
			ImmutableList.copyOf(orderKeys),
			RexWindowBound.create(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO), null),
			RexWindowBound.create(SqlWindow.createUnboundedFollowing(SqlParserPos.ZERO), null),
			true,
			true,
			false
	);
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:30,代码来源:JdbcRelBuilder.java

示例5: HistogramShuttle

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
HistogramShuttle(
	List<RexNode> partitionKeys,
	ImmutableList<RexFieldCollation> orderKeys,
	RexWindowBound lowerBound, RexWindowBound upperBound,
	SqlWindow window) {
	this.partitionKeys = partitionKeys;
	this.orderKeys = orderKeys;
	this.lowerBound = lowerBound;
	this.upperBound = upperBound;
	this.window = window;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:SqlToRelConverter.java

示例6: HistogramShuttle

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
HistogramShuttle(
        List<RexNode> partitionKeys,
        ImmutableList<RexFieldCollation> orderKeys,
        RexWindowBound lowerBound, RexWindowBound upperBound,
        SqlWindow window,
        boolean distinct) {
  this.partitionKeys = partitionKeys;
  this.orderKeys = orderKeys;
  this.lowerBound = lowerBound;
  this.upperBound = upperBound;
  this.window = window;
  this.distinct = distinct;
}
 
开发者ID:apache,项目名称:kylin,代码行数:14,代码来源:SqlToRelConverter.java

示例7: addWindows

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
private static void addWindows(
    Multimap<WindowKey, RexOver> windowMap,
    RexOver over, final int inputFieldCount) {
  final RexWindow aggWindow = over.getWindow();

  // Look up or create a window.
  RelCollation orderKeys = getCollation(
      Lists.newArrayList(
          Iterables.filter(aggWindow.orderKeys,
            new PredicateImpl<RexFieldCollation>() {
              public boolean test(RexFieldCollation rexFieldCollation) {
                // If ORDER BY references constant (i.e. RexInputRef),
                // then we can ignore such ORDER BY key.
                return rexFieldCollation.left instanceof RexLocalRef;
              }
            })));
  ImmutableBitSet groupSet =
      ImmutableBitSet.of(getProjectOrdinals(aggWindow.partitionKeys));
  final int groupLength = groupSet.length();
  if (inputFieldCount < groupLength) {
    // If PARTITION BY references constant, we can ignore such partition key.
    // All the inputs after inputFieldCount are literals, thus we can clear.
    groupSet =
        groupSet.except(ImmutableBitSet.range(inputFieldCount, groupLength));
  }

  WindowKey windowKey =
      new WindowKey(
          groupSet, orderKeys, aggWindow.isRows(),
          aggWindow.getLowerBound(), aggWindow.getUpperBound());
  windowMap.put(windowKey, over);
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:LogicalWindow.java

示例8: HistogramShuttle

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
HistogramShuttle(
    List<RexNode> partitionKeys,
    ImmutableList<RexFieldCollation> orderKeys,
    RexWindowBound lowerBound, RexWindowBound upperBound,
    SqlWindow window,
    boolean distinct) {
  this.partitionKeys = partitionKeys;
  this.orderKeys = orderKeys;
  this.lowerBound = lowerBound;
  this.upperBound = upperBound;
  this.window = window;
  this.distinct = distinct;
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:SqlToRelConverter.java

示例9: convertOver

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
	SqlCall call = (SqlCall) node;
	SqlCall aggCall = call.operand(0);
	SqlNode windowOrRef = call.operand(1);
	final SqlWindow window =
		validator.resolveWindow(windowOrRef, bb.scope, true);

	// ROW_NUMBER() expects specific kind of framing.
	if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
		window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
		window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
		window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
	}
	final SqlNodeList partitionList = window.getPartitionList();
	final ImmutableList.Builder<RexNode> partitionKeys =
		ImmutableList.builder();
	for (SqlNode partition : partitionList) {
		partitionKeys.add(bb.convertExpression(partition));
	}
	RexNode lowerBound = bb.convertExpression(window.getLowerBound());
	RexNode upperBound = bb.convertExpression(window.getUpperBound());
	SqlNodeList orderList = window.getOrderList();
	if ((orderList.size() == 0) && !window.isRows()) {
		// A logical range requires an ORDER BY clause. Use the implicit
		// ordering of this relation. There must be one, otherwise it would
		// have failed validation.
		orderList = bb.scope.getOrderList();
		if (orderList == null) {
			throw new AssertionError(
				"Relation should have sort key for implicit ORDER BY");
		}
	}
	final ImmutableList.Builder<RexFieldCollation> orderKeys =
		ImmutableList.builder();
	final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
	for (SqlNode order : orderList) {
		flags.clear();
		RexNode e = bb.convertSortExpression(order, flags);
		orderKeys.add(new RexFieldCollation(e, flags));
	}
	try {
		Preconditions.checkArgument(bb.window == null,
			"already in window agg mode");
		bb.window = window;
		RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
		rexAgg =
			rexBuilder.ensureType(
				validator.getValidatedNodeType(call), rexAgg, false);

		// Walk over the tree and apply 'over' to all agg functions. This is
		// necessary because the returned expression is not necessarily a call
		// to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).
		final RexShuttle visitor =
			new HistogramShuttle(
				partitionKeys.build(), orderKeys.build(),
				RexWindowBound.create(window.getLowerBound(), lowerBound),
				RexWindowBound.create(window.getUpperBound(), upperBound),
				window);
		return rexAgg.accept(visitor);
	} finally {
		bb.window = null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:64,代码来源:SqlToRelConverter.java

示例10: convertOver

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
  SqlCall call = (SqlCall) node;
  SqlCall aggCall = call.operand(0);
  SqlNode windowOrRef = call.operand(1);
  final SqlWindow window =
      validator.resolveWindow(windowOrRef, bb.scope, true);

  // ROW_NUMBER() expects specific kind of framing.
  if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
    window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
    window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
    window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
  }
  final SqlNodeList partitionList = window.getPartitionList();
  final ImmutableList.Builder<RexNode> partitionKeys =
      ImmutableList.builder();
  for (SqlNode partition : partitionList) {
    partitionKeys.add(bb.convertExpression(partition));
  }
  RexNode lowerBound = bb.convertExpression(window.getLowerBound());
  RexNode upperBound = bb.convertExpression(window.getUpperBound());
  SqlNodeList orderList = window.getOrderList();
  if ((orderList.size() == 0) && !window.isRows()) {
    // A logical range requires an ORDER BY clause. Use the implicit
    // ordering of this relation. There must be one, otherwise it would
    // have failed validation.
    orderList = bb.scope.getOrderList();
    if (orderList == null) {
      throw new AssertionError(
          "Relation should have sort key for implicit ORDER BY");
    }
  }
  final ImmutableList.Builder<RexFieldCollation> orderKeys =
      ImmutableList.builder();
  final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
  for (SqlNode order : orderList) {
    flags.clear();
    RexNode e = bb.convertSortExpression(order, flags);
    orderKeys.add(new RexFieldCollation(e, flags));
  }
  try {
    Preconditions.checkArgument(bb.window == null,
        "already in window agg mode");
    bb.window = window;
    RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
    rexAgg =
        rexBuilder.ensureType(
            validator.getValidatedNodeType(call), rexAgg, false);

    // Walk over the tree and apply 'over' to all agg functions. This is
    // necessary because the returned expression is not necessarily a call
    // to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).

    boolean isDistinct = false;
    if (aggCall.getFunctionQuantifier() != null
      && aggCall.getFunctionQuantifier().getValue().equals(SqlSelectKeyword.DISTINCT)) {
      isDistinct = true;
    }

    final RexShuttle visitor =
        new HistogramShuttle(
            partitionKeys.build(), orderKeys.build(),
            RexWindowBound.create(window.getLowerBound(), lowerBound),
            RexWindowBound.create(window.getUpperBound(), upperBound),
            window,
            isDistinct);
    RexNode overNode = rexAgg.accept(visitor);

    return overNode;
  } finally {
    bb.window = null;
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:74,代码来源:SqlToRelConverter.java

示例11: convertOver

import org.apache.calcite.rex.RexFieldCollation; //导入依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
  SqlCall call = (SqlCall) node;
  SqlCall aggCall = call.operand(0);
  SqlNode windowOrRef = call.operand(1);
  final SqlWindow window =
      validator.resolveWindow(windowOrRef, bb.scope, true);

  // ROW_NUMBER() expects specific kind of framing.
  if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
    window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
    window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
    window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
  }
  final SqlNodeList partitionList = window.getPartitionList();
  final ImmutableList.Builder<RexNode> partitionKeys =
      ImmutableList.builder();
  for (SqlNode partition : partitionList) {
    partitionKeys.add(bb.convertExpression(partition));
  }
  RexNode lowerBound = bb.convertExpression(window.getLowerBound());
  RexNode upperBound = bb.convertExpression(window.getUpperBound());
  SqlNodeList orderList = window.getOrderList();
  if ((orderList.size() == 0) && !window.isRows()) {
    // A logical range requires an ORDER BY clause. Use the implicit
    // ordering of this relation. There must be one, otherwise it would
    // have failed validation.
    orderList = bb.scope.getOrderList();
    if (orderList == null) {
      throw new AssertionError(
          "Relation should have sort key for implicit ORDER BY");
    }
  }
  final ImmutableList.Builder<RexFieldCollation> orderKeys =
      ImmutableList.builder();
  final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
  for (SqlNode order : orderList) {
    flags.clear();
    RexNode e = bb.convertSortExpression(order, flags);
    orderKeys.add(new RexFieldCollation(e, flags));
  }
  try {
    Preconditions.checkArgument(bb.window == null,
        "already in window agg mode");
    bb.window = window;
    RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
    rexAgg =
        rexBuilder.ensureType(
            validator.getValidatedNodeType(call), rexAgg, false);

    // Walk over the tree and apply 'over' to all agg functions. This is
    // necessary because the returned expression is not necessarily a call
    // to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).

    final SqlLiteral q = aggCall.getFunctionQuantifier();
    final boolean isDistinct = q != null
        && q.getValue() == SqlSelectKeyword.DISTINCT;

    final RexShuttle visitor =
        new HistogramShuttle(
            partitionKeys.build(), orderKeys.build(),
            RexWindowBound.create(window.getLowerBound(), lowerBound),
            RexWindowBound.create(window.getUpperBound(), upperBound),
            window,
            isDistinct);
    RexNode overNode = rexAgg.accept(visitor);

    return overNode;
  } finally {
    bb.window = null;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:72,代码来源:SqlToRelConverter.java


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