use of org.apache.calcite.rel.core.Project in project druid by druid-io.
the class DruidRelsTest method test_isScanOrMapping_mappingJoin.
@Test
public void test_isScanOrMapping_mappingJoin() {
final Project project = mockMappingProject(ImmutableList.of(1, 0), 2);
final DruidRel<?> rel = mockDruidRel(DruidJoinQueryRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, null);
Assert.assertTrue(DruidRels.isScanOrMapping(rel, true));
Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
use of org.apache.calcite.rel.core.Project in project druid by druid-io.
the class DruidRelsTest method test_isScanOrMapping_mappingUnion.
@Test
public void test_isScanOrMapping_mappingUnion() {
final Project project = mockMappingProject(ImmutableList.of(1, 0), 2);
final DruidRel<?> rel = mockDruidRel(DruidUnionDataSourceRel.class, PartialDruidQuery.Stage.SELECT_PROJECT, null, project, null);
Assert.assertTrue(DruidRels.isScanOrMapping(rel, true));
Assert.assertFalse(DruidRels.isScanOrMapping(rel, false));
EasyMock.verify(rel, rel.getPartialDruidQuery(), project);
}
use of org.apache.calcite.rel.core.Project in project beam by apache.
the class BeamAggregateProjectMergeRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(1);
BeamIOSourceRel io = getUnderlyingIO(new HashSet<>(), project);
// supported.
if (io == null || !io.getBeamSqlTable().supportsProjects().isSupported()) {
super.onMatch(call);
}
}
use of org.apache.calcite.rel.core.Project in project beam by apache.
the class BeamBasicAggregationRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
Aggregate aggregate = call.rel(0);
RelNode relNode = call.rel(1);
if (aggregate.getGroupType() != Aggregate.Group.SIMPLE) {
return;
}
if (relNode instanceof Project || relNode instanceof Calc || relNode instanceof Filter) {
if (isWindowed(relNode) || hasWindowedParents(relNode)) {
// This case is expected to get handled by the 'BeamAggregationRule'
return;
}
}
RelNode newTableScan = relNode.copy(relNode.getTraitSet(), relNode.getInputs());
call.transformTo(new BeamAggregationRel(aggregate.getCluster(), aggregate.getTraitSet().replace(BeamLogicalConvention.INSTANCE), convert(newTableScan, newTableScan.getTraitSet().replace(BeamLogicalConvention.INSTANCE)), aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList(), null, -1));
}
use of org.apache.calcite.rel.core.Project in project druid by druid-io.
the class DruidQuery method computeGrouping.
@Nonnull
private static Grouping computeGrouping(final PartialDruidQuery partialQuery, final PlannerContext plannerContext, final RowSignature rowSignature, final VirtualColumnRegistry virtualColumnRegistry, final RexBuilder rexBuilder, final boolean finalizeAggregations) {
final Aggregate aggregate = Preconditions.checkNotNull(partialQuery.getAggregate(), "aggregate");
final Project aggregateProject = partialQuery.getAggregateProject();
final List<DimensionExpression> dimensions = computeDimensions(partialQuery, plannerContext, rowSignature, virtualColumnRegistry);
final Subtotals subtotals = computeSubtotals(partialQuery, rowSignature);
final List<Aggregation> aggregations = computeAggregations(partialQuery, plannerContext, rowSignature, virtualColumnRegistry, rexBuilder, finalizeAggregations);
final RowSignature aggregateRowSignature = RowSignatures.fromRelDataType(ImmutableList.copyOf(Iterators.concat(dimensions.stream().map(DimensionExpression::getOutputName).iterator(), aggregations.stream().map(Aggregation::getOutputName).iterator())), aggregate.getRowType());
final DimFilter havingFilter = computeHavingFilter(partialQuery, plannerContext, aggregateRowSignature);
final Grouping grouping = Grouping.create(dimensions, subtotals, aggregations, havingFilter, aggregateRowSignature);
if (aggregateProject == null) {
return grouping;
} else {
return grouping.applyProject(plannerContext, aggregateProject);
}
}
Aggregations