Search in sources :

Example 21 with GroupOperation

use of com.yahoo.bullet.querying.aggregations.grouping.GroupOperation in project bullet-core by yahoo.

the class GroupAllTest method testToString.

@Test
public void testToString() {
    GroupOperation operation = new GroupOperation(GroupOperation.GroupOperationType.SUM, "abc", "sum");
    GroupAll aggregation = new GroupAll(Collections.singleton(operation));
    Assert.assertEquals(aggregation.toString(), "{size: null, type: GROUP, operations: [{type: SUM, field: abc, name: sum}]}");
}
Also used : GroupOperation(com.yahoo.bullet.querying.aggregations.grouping.GroupOperation) Test(org.testng.annotations.Test)

Example 22 with GroupOperation

use of com.yahoo.bullet.querying.aggregations.grouping.GroupOperation in project bullet-core by yahoo.

the class GroupAllTest method testCountFieldInvalid.

@Test(expectedExceptions = BulletException.class, expectedExceptionsMessageRegExp = "COUNT_FIELD is not a valid operation\\.")
public void testCountFieldInvalid() {
    GroupOperation operation = new GroupOperation(GroupOperation.GroupOperationType.COUNT_FIELD, "abc", null);
    new GroupAll(Collections.singleton(operation));
}
Also used : GroupOperation(com.yahoo.bullet.querying.aggregations.grouping.GroupOperation) Test(org.testng.annotations.Test)

Example 23 with GroupOperation

use of com.yahoo.bullet.querying.aggregations.grouping.GroupOperation in project bullet-core by yahoo.

the class GroupByTest method testCountFieldInvalid.

@Test(expectedExceptions = BulletException.class, expectedExceptionsMessageRegExp = "COUNT_FIELD is not a valid operation\\.")
public void testCountFieldInvalid() {
    GroupOperation operation = new GroupOperation(GroupOperation.GroupOperationType.COUNT_FIELD, "abc", null);
    new GroupBy(null, Collections.singletonMap("abc", "def"), Collections.singleton(operation));
}
Also used : GroupOperation(com.yahoo.bullet.querying.aggregations.grouping.GroupOperation) Test(org.testng.annotations.Test)

Example 24 with GroupOperation

use of com.yahoo.bullet.querying.aggregations.grouping.GroupOperation in project bullet-core by yahoo.

the class GroupByTest method testOperations.

@Test
public void testOperations() {
    GroupBy aggregation = new GroupBy(null, Collections.singletonMap("abc", "def"), Collections.emptySet());
    Assert.assertEquals(aggregation.getOperations(), Collections.emptySet());
    Set<GroupOperation> operations = new HashSet<>();
    operations.add(new GroupOperation(GroupOperation.GroupOperationType.SUM, "abc", "sum"));
    operations.add(new GroupOperation(GroupOperation.GroupOperationType.COUNT, null, "count"));
    aggregation = new GroupBy(null, Collections.singletonMap("abc", "def"), operations);
    Assert.assertEquals(aggregation.getOperations(), new HashSet<>(Arrays.asList(new GroupOperation(GroupOperation.GroupOperationType.SUM, "abc", "sum"), new GroupOperation(GroupOperation.GroupOperationType.COUNT, null, "count"))));
}
Also used : GroupOperation(com.yahoo.bullet.querying.aggregations.grouping.GroupOperation) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

GroupOperation (com.yahoo.bullet.querying.aggregations.grouping.GroupOperation)24 Test (org.testng.annotations.Test)23 BulletRecord (com.yahoo.bullet.record.BulletRecord)18 Clip (com.yahoo.bullet.result.Clip)7 BulletConfig (com.yahoo.bullet.common.BulletConfig)6 GroupBy (com.yahoo.bullet.query.aggregations.GroupBy)6 RecordBox (com.yahoo.bullet.result.RecordBox)6 Collections.singletonMap (java.util.Collections.singletonMap)6 HashSet (java.util.HashSet)6 List (java.util.List)6 Map (java.util.Map)6 IntStream (java.util.stream.IntStream)6 Pair (org.apache.commons.lang3.tuple.Pair)6 Assert (org.testng.Assert)6 TestHelpers.addMetadata (com.yahoo.bullet.TestHelpers.addMetadata)5 TestHelpers.assertContains (com.yahoo.bullet.TestHelpers.assertContains)5 AggregationUtils.makeGroupFields (com.yahoo.bullet.querying.aggregations.AggregationUtils.makeGroupFields)5 COUNT (com.yahoo.bullet.querying.aggregations.grouping.GroupOperation.GroupOperationType.COUNT)5 SUM (com.yahoo.bullet.querying.aggregations.grouping.GroupOperation.GroupOperationType.SUM)5 KMVSketch (com.yahoo.bullet.querying.aggregations.sketches.KMVSketch)5