本文整理了Java中org.apache.calcite.rel.core.Aggregate.getTraitSet()
方法的一些代码示例,展示了Aggregate.getTraitSet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aggregate.getTraitSet()
方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Aggregate
类名称:Aggregate
方法名:getTraitSet
暂无
代码示例来源:origin: apache/hive
return aggregate.copy(aggregate.getTraitSet(), project, false,
ImmutableBitSet.range(projects.size()),
null, ImmutableList.<AggregateCall>of());
代码示例来源:origin: apache/hive
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: apache/hive
rewriteAggCalls(newAggCalls, argList, sourceOf);
final int cardinality = aggregate.getGroupSet().cardinality();
return aggregate.copy(aggregate.getTraitSet(), distinct,
aggregate.indicator, ImmutableBitSet.range(cardinality), null,
newAggCalls);
代码示例来源:origin: apache/drill
return aggregate.copy(aggregate.getTraitSet(), project, false,
ImmutableBitSet.range(projects.size()),
null, ImmutableList.<AggregateCall>of());
代码示例来源:origin: apache/hive
final Aggregate newAggregate = aggRel.copy(aggRel.getTraitSet(), aggRel.getInput(),
aggRel.indicator, aggRel.getGroupSet(), aggRel.getGroupSets(),
newAggCalls);
代码示例来源:origin: apache/drill
rewriteAggCalls(newAggCalls, argList, sourceOf);
final int cardinality = aggregate.getGroupSet().cardinality();
return aggregate.copy(aggregate.getTraitSet(), distinct,
aggregate.indicator, ImmutableBitSet.range(cardinality), null,
newAggCalls);
代码示例来源:origin: apache/incubator-druid
aggregate.getTraitSet(),
aggregate.getInput(),
aggregate.indicator,
代码示例来源:origin: apache/drill
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
// 1) We extract the group by positions that are part of the collations and
// sort them so they respect it
LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
if (!rel.indicator && !collations.isEmpty()) {
for (RelFieldCollation c : collations) {
if (c.getFieldIndex() < rel.getGroupCount()) {
// Group column found
if (aggregateColumnsOrder.add(c.getFieldIndex())) {
propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
}
}
}
}
for (int i = 0; i < rel.getGroupCount(); i++) {
if (!aggregateColumnsOrder.contains(i)) {
// Not included in the input collations, but can be propagated as this Aggregate
// will enforce it
propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
}
}
// 2) We propagate
final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
// 3) We annotate the Aggregate operator with this info
final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
ImmutableList.of(child));
newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
return newAggregate;
}
代码示例来源:origin: apache/hive
Aggregate newAggregate = new HiveAggregate(aggregate.getCluster(), aggregate.getTraitSet(), relBuilder.build(),
aggregate.getGroupSet(), null, aggregate.getAggCallList());
return newAggregate;
代码示例来源:origin: apache/hive
aggregate.getTraitSet(), relBuilder.build(),
false, ImmutableBitSet.of(bottomGroupSet), null, bottomAggregateCalls));
aggregate.copy(aggregate.getTraitSet(),
relBuilder.build(), aggregate.indicator,
ImmutableBitSet.of(topGroupSet), null, topAggregateCalls));
代码示例来源:origin: org.apache.drill.exec/drill-java-exec
@Override
public boolean matches(RelOptRuleCall call) {
final Filter filter = call.rel(0);
final Aggregate aggregate = call.rel(1);
return filter.getTraitSet().getTrait(ConventionTraitDef.INSTANCE)
== aggregate.getTraitSet().getTrait(ConventionTraitDef.INSTANCE);
}
代码示例来源:origin: Qihoo360/Quicksql
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final DruidQuery query = call.rel(1);
if (!DruidQuery.isValidSignature(query.signature() + 'a')) {
return;
}
if (aggregate.indicator
|| aggregate.getGroupSets().size() != 1
|| BAD_AGG.apply(ImmutableTriple.of(aggregate, (RelNode) aggregate, query))
|| !validAggregate(aggregate, query)) {
return;
}
final RelNode newAggregate = aggregate.copy(aggregate.getTraitSet(),
ImmutableList.of(Util.last(query.rels)));
call.transformTo(DruidQuery.extendQuery(query, newAggregate));
}
代码示例来源:origin: Qihoo360/Quicksql
public RelNode convert(RelNode rel) {
final Aggregate agg = (Aggregate) rel;
if (agg.getGroupSets().size() != 1) {
// GROUPING SETS not supported; see
// [CALCITE-734] Push GROUPING SETS to underlying SQL via JDBC adapter
return null;
}
final RelTraitSet traitSet =
agg.getTraitSet().replace(out);
try {
return new JdbcAggregate(rel.getCluster(), traitSet,
convert(agg.getInput(), out), agg.indicator, agg.getGroupSet(),
agg.getGroupSets(), agg.getAggCallList());
} catch (InvalidRelException e) {
LOGGER.debug(e.toString());
return null;
}
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
public RelNode convert(RelNode rel) {
final Aggregate agg = (Aggregate) rel;
if (agg.getGroupSets().size() != 1) {
// GROUPING SETS not supported; see
// [CALCITE-734] Push GROUPING SETS to underlying SQL via JDBC adapter
return null;
}
final RelTraitSet traitSet =
agg.getTraitSet().replace(out);
try {
return new JdbcAggregate(rel.getCluster(), traitSet,
convert(agg.getInput(), out), agg.indicator, agg.getGroupSet(),
agg.getGroupSets(), agg.getAggCallList());
} catch (InvalidRelException e) {
LOGGER.debug(e.toString());
return null;
}
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
final int cardinality = aggregate.getGroupSet().cardinality();
relBuilder.push(
aggregate.copy(aggregate.getTraitSet(), relBuilder.build(),
aggregate.indicator, ImmutableBitSet.range(cardinality), null,
newAggCalls));
代码示例来源:origin: com.alibaba.blink/flink-table
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final RelNode input = call.rel(1);
// Distinct is "GROUP BY c1, c2" (where c1, c2 are a set of columns on
// which the input is unique, i.e. contain a key) and has no aggregate
// functions or the functions we enumerated. It can be removed.
final RelNode newInput = convert(input, aggregate.getTraitSet().simplify());
// If aggregate was projecting a subset of columns, add a project for the
// same effect.
final RelBuilder relBuilder = call.builder();
relBuilder.push(newInput);
List<Integer> projectIndices = new ArrayList<>(aggregate.getGroupSet().asList());
for (AggregateCall aggCall : aggregate.getAggCallList()) {
projectIndices.addAll(aggCall.getArgList());
}
relBuilder.project(relBuilder.fields(projectIndices));
// Create a project if some of the columns have become
// NOT NULL due to aggregate functions are removed
relBuilder.convert(aggregate.getRowType(), true);
call.transformTo(relBuilder.build());
}
}
代码示例来源:origin: Qihoo360/Quicksql
return;
rel = aggRel.copy(aggRel.getTraitSet(), ImmutableList.of(rel));
rel = builder.push(rel).filter(remainingConditions).build();
call.transformTo(rel);
代码示例来源:origin: org.apache.calcite/calcite-druid
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final DruidQuery query = call.rel(1);
final RelNode topDruidNode = query.getTopNode();
final Project project = topDruidNode instanceof Project ? (Project) topDruidNode : null;
if (!DruidQuery.isValidSignature(query.signature() + 'a')) {
return;
}
if (aggregate.indicator
|| aggregate.getGroupSets().size() != 1) {
return;
}
if (DruidQuery
.computeProjectGroupSet(project, aggregate.getGroupSet(), query.table.getRowType(), query)
== null) {
return;
}
final List<String> aggNames = Util
.skip(aggregate.getRowType().getFieldNames(), aggregate.getGroupSet().cardinality());
if (DruidQuery.computeDruidJsonAgg(aggregate.getAggCallList(), aggNames, project, query)
== null) {
return;
}
final RelNode newAggregate = aggregate
.copy(aggregate.getTraitSet(), ImmutableList.of(query.getTopNode()));
call.transformTo(DruidQuery.extendQuery(query, newAggregate));
}
}
代码示例来源:origin: Qihoo360/Quicksql
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final RelNode input = call.rel(1);
if (!aggregate.getAggCallList().isEmpty() || aggregate.indicator) {
return;
}
final RelMetadataQuery mq = call.getMetadataQuery();
if (!SqlFunctions.isTrue(mq.areColumnsUnique(input, aggregate.getGroupSet()))) {
return;
}
// Distinct is "GROUP BY c1, c2" (where c1, c2 are a set of columns on
// which the input is unique, i.e. contain a key) and has no aggregate
// functions. It can be removed.
final RelNode newInput = convert(input, aggregate.getTraitSet().simplify());
// If aggregate was projecting a subset of columns, add a project for the
// same effect.
final RelBuilder relBuilder = call.builder();
relBuilder.push(newInput);
if (newInput.getRowType().getFieldCount()
> aggregate.getRowType().getFieldCount()) {
relBuilder.project(relBuilder.fields(aggregate.getGroupSet().asList()));
}
call.transformTo(relBuilder.build());
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
public void onMatch(RelOptRuleCall call) {
final Aggregate aggregate = call.rel(0);
final RelNode input = call.rel(1);
if (!aggregate.getAggCallList().isEmpty() || aggregate.indicator) {
return;
}
final RelMetadataQuery mq = call.getMetadataQuery();
if (!SqlFunctions.isTrue(mq.areColumnsUnique(input, aggregate.getGroupSet()))) {
return;
}
// Distinct is "GROUP BY c1, c2" (where c1, c2 are a set of columns on
// which the input is unique, i.e. contain a key) and has no aggregate
// functions. It can be removed.
final RelNode newInput = convert(input, aggregate.getTraitSet().simplify());
// If aggregate was projecting a subset of columns, add a project for the
// same effect.
final RelBuilder relBuilder = call.builder();
relBuilder.push(newInput);
if (newInput.getRowType().getFieldCount()
> aggregate.getRowType().getFieldCount()) {
relBuilder.project(relBuilder.fields(aggregate.getGroupSet().asList()));
}
call.transformTo(relBuilder.build());
}
}
内容来源于网络,如有侵权,请联系作者删除!