Search in sources :

Example 6 with HashAggregate

use of org.apache.drill.exec.physical.config.HashAggregate in project drill by apache.

the class TestNullInputMiniPlan method testHashAggEmpty.

@Test
public void testHashAggEmpty() throws Exception {
    final PhysicalOperator hashAgg = new HashAggregate(null, AggPrelBase.OperatorPhase.PHASE_1of1, parseExprs("a", "a"), parseExprs("sum(b)", "b_sum"), 1.0f);
    testSingleInputNullBatchHandling(hashAgg);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) HashAggregate(org.apache.drill.exec.physical.config.HashAggregate) Test(org.junit.Test)

Example 7 with HashAggregate

use of org.apache.drill.exec.physical.config.HashAggregate in project drill by apache.

the class BasicPhysicalOpUnitTest method testSimpleHashAgg.

@Test
public void testSimpleHashAgg() {
    HashAggregate aggConf = new HashAggregate(null, AggPrelBase.OperatorPhase.PHASE_1of1, parseExprs("a", "a"), parseExprs("sum(b)", "b_sum"), 1.0f);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]");
    legacyOpTestBuilder().physicalOperator(aggConf).inputDataStreamJson(inputJsonBatches).baselineColumns("b_sum", "a").baselineValues(6l, 5l).baselineValues(8l, 3l).go();
}
Also used : HashAggregate(org.apache.drill.exec.physical.config.HashAggregate) Test(org.junit.Test)

Example 8 with HashAggregate

use of org.apache.drill.exec.physical.config.HashAggregate in project drill by axbaretto.

the class TestNullInputMiniPlan method testHashAggEmpty.

@Test
public void testHashAggEmpty() throws Exception {
    final PhysicalOperator hashAgg = new HashAggregate(null, AggPrelBase.OperatorPhase.PHASE_1of1, parseExprs("a", "a"), parseExprs("sum(b)", "b_sum"), 1.0f);
    testSingleInputNullBatchHandling(hashAgg);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) HashAggregate(org.apache.drill.exec.physical.config.HashAggregate) Test(org.junit.Test)

Example 9 with HashAggregate

use of org.apache.drill.exec.physical.config.HashAggregate in project drill by apache.

the class TestHashAggBatch method createHashAggPhysicalOperator.

private HashAggregate createHashAggPhysicalOperator(AggPrelBase.OperatorPhase phase) {
    final List<NamedExpression> keyExpressions = Lists.newArrayList(new NamedExpression(SchemaPath.getSimplePath(FIRST_NAME_COL), new FieldReference(FIRST_NAME_COL)), new NamedExpression(SchemaPath.getSimplePath(LAST_NAME_COL), new FieldReference(LAST_NAME_COL)));
    final List<NamedExpression> aggExpressions = Lists.newArrayList(new NamedExpression(new FunctionCall("sum", ImmutableList.of(SchemaPath.getSimplePath(STUFF_COL)), new ExpressionPosition(null, 0)), new FieldReference(TOTAL_STUFF_COL)));
    return new HashAggregate(null, phase, keyExpressions, aggExpressions, 0.0f);
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) FunctionCall(org.apache.drill.common.expression.FunctionCall) ExpressionPosition(org.apache.drill.common.expression.ExpressionPosition) HashAggregate(org.apache.drill.exec.physical.config.HashAggregate)

Example 10 with HashAggregate

use of org.apache.drill.exec.physical.config.HashAggregate in project drill by apache.

the class TestHashAggBatch method batchSumTest.

private void batchSumTest(int totalCount, int maxInputBatchSize, AggPrelBase.OperatorPhase phase) throws Exception {
    final HashAggregate hashAggregate = createHashAggPhysicalOperator(phase);
    final List<RowSet> inputRowSets = buildInputRowSets(TypeProtos.MinorType.INT, TypeProtos.DataMode.REQUIRED, totalCount, maxInputBatchSize);
    final MockRecordBatch.Builder rowSetBatchBuilder = new MockRecordBatch.Builder();
    inputRowSets.forEach(rowSet -> rowSetBatchBuilder.sendData(rowSet));
    final MockRecordBatch inputRowSetBatch = rowSetBatchBuilder.build(fragContext);
    final RowSet expectedRowSet = buildIntExpectedRowSet(totalCount);
    opTestBuilder().physicalOperator(hashAggregate).combineOutputBatches().unordered().addUpstreamBatch(inputRowSetBatch).addExpectedResult(expectedRowSet).go();
}
Also used : SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) MockRecordBatch(org.apache.drill.exec.physical.impl.MockRecordBatch) HashAggregate(org.apache.drill.exec.physical.config.HashAggregate)

Aggregations

HashAggregate (org.apache.drill.exec.physical.config.HashAggregate)13 Test (org.junit.Test)8 LegacyOperatorTestBuilder (org.apache.drill.test.LegacyOperatorTestBuilder)3 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)2 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)2 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)2 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)2 ExpressionPosition (org.apache.drill.common.expression.ExpressionPosition)1 FieldReference (org.apache.drill.common.expression.FieldReference)1 FunctionCall (org.apache.drill.common.expression.FunctionCall)1 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)1 HashAggBatch (org.apache.drill.exec.physical.impl.aggregate.HashAggBatch)1 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)1 RecordBatch (org.apache.drill.exec.record.RecordBatch)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)1