use of org.apache.druid.segment.data.ComparableList in project druid by druid-io.
the class GroupByQueryRunnerTest method testNestedGroupByWithLongArrays.
@Test
public void testNestedGroupByWithLongArrays() {
if (config.getDefaultStrategy().equals(GroupByStrategySelector.STRATEGY_V1)) {
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("GroupBy v1 only supports dimensions with an outputType of STRING");
}
cannotVectorize();
GroupByQuery inner = makeQueryBuilder().setDataSource(QueryRunnerTestHelper.DATA_SOURCE).setQuerySegmentSpec(QueryRunnerTestHelper.FIRST_TO_THIRD).setVirtualColumns(new ExpressionVirtualColumn("v0", "array(1,2)", ColumnType.LONG_ARRAY, ExprMacroTable.nil())).setDimensions(new DefaultDimensionSpec("v0", "alias", ColumnType.LONG_ARRAY)).setAggregatorSpecs(QueryRunnerTestHelper.ROWS_COUNT).setGranularity(QueryRunnerTestHelper.ALL_GRAN).build();
GroupByQuery outer = makeQueryBuilder().setDataSource(new QueryDataSource(inner)).setQuerySegmentSpec(QueryRunnerTestHelper.FIRST_TO_THIRD).setDimensions(new DefaultDimensionSpec("alias", "alias_outer", ColumnType.LONG_ARRAY)).setAggregatorSpecs(QueryRunnerTestHelper.ROWS_COUNT).setGranularity(QueryRunnerTestHelper.ALL_GRAN).build();
List<ResultRow> expectedResults = ImmutableList.of(makeRow(outer, "2011-04-01", "alias_outer", new ComparableList(ImmutableList.of(1L, 2L)), "rows", 1L));
Iterable<ResultRow> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, outer);
TestHelper.assertExpectedObjects(expectedResults, results, "long-nested-groupby-arrays");
}
use of org.apache.druid.segment.data.ComparableList in project druid by druid-io.
the class ArrayDoubleGroupByColumnSelectorStrategyTest method testAddingInDictionary.
@Test
public void testAddingInDictionary() {
ColumnValueSelector columnValueSelector = Mockito.mock(ColumnValueSelector.class);
Mockito.when(columnValueSelector.getObject()).thenReturn(ImmutableList.of(4.0, 2.0));
Assert.assertEquals(3, strategy.getOnlyValue(columnValueSelector));
GroupByColumnSelectorPlus groupByColumnSelectorPlus = Mockito.mock(GroupByColumnSelectorPlus.class);
Mockito.when(groupByColumnSelectorPlus.getResultRowPosition()).thenReturn(0);
ResultRow row = ResultRow.create(1);
buffer1.putInt(3);
strategy.processValueFromGroupingKey(groupByColumnSelectorPlus, buffer1, row, 0);
Assert.assertEquals(new ComparableList(ImmutableList.of(4.0, 2.0)), row.get(0));
}
use of org.apache.druid.segment.data.ComparableList in project druid by druid-io.
the class ClientQuerySegmentWalkerTest method testGroupByOnArraysDoublesAsString.
@Test
public void testGroupByOnArraysDoublesAsString() {
final GroupByQuery query = (GroupByQuery) GroupByQuery.builder().setDataSource(ARRAY).setGranularity(Granularities.ALL).setInterval(Collections.singletonList(INTERVAL)).setDimensions(DefaultDimensionSpec.of("ad")).build().withId(DUMMY_QUERY_ID);
testQuery(query, ImmutableList.of(ExpectedQuery.cluster(query)), ImmutableList.of(new Object[] { new ComparableList(ImmutableList.of(1.0, 2.0)).toString() }, new Object[] { new ComparableList(ImmutableList.of(2.0, 4.0)).toString() }, new Object[] { new ComparableList(ImmutableList.of(3.0, 6.0)).toString() }, new Object[] { new ComparableList(ImmutableList.of(4.0, 8.0)).toString() }));
}
use of org.apache.druid.segment.data.ComparableList in project druid by druid-io.
the class ClientQuerySegmentWalkerTest method testGroupByOnArraysLongs.
@Test
public void testGroupByOnArraysLongs() {
final GroupByQuery query = (GroupByQuery) GroupByQuery.builder().setDataSource(ARRAY).setGranularity(Granularities.ALL).setInterval(Collections.singletonList(INTERVAL)).setDimensions(new DefaultDimensionSpec("al", "al", ColumnType.LONG_ARRAY)).build().withId(DUMMY_QUERY_ID);
testQuery(query, ImmutableList.of(ExpectedQuery.cluster(query)), ImmutableList.of(new Object[] { new ComparableList(ImmutableList.of(1L, 2L)) }, new Object[] { new ComparableList(ImmutableList.of(2L, 4L)) }, new Object[] { new ComparableList(ImmutableList.of(3L, 6L)) }, new Object[] { new ComparableList(ImmutableList.of(4L, 8L)) }));
}
use of org.apache.druid.segment.data.ComparableList in project druid by druid-io.
the class ClientQuerySegmentWalkerTest method testGroupByOnArraysDoubles.
@Test
public void testGroupByOnArraysDoubles() {
final GroupByQuery query = (GroupByQuery) GroupByQuery.builder().setDataSource(ARRAY).setGranularity(Granularities.ALL).setInterval(Collections.singletonList(INTERVAL)).setDimensions(new DefaultDimensionSpec("ad", "ad", ColumnType.DOUBLE_ARRAY)).build().withId(DUMMY_QUERY_ID);
testQuery(query, ImmutableList.of(ExpectedQuery.cluster(query)), ImmutableList.of(new Object[] { new ComparableList(ImmutableList.of(1.0, 2.0)) }, new Object[] { new ComparableList(ImmutableList.of(2.0, 4.0)) }, new Object[] { new ComparableList(ImmutableList.of(3.0, 6.0)) }, new Object[] { new ComparableList(ImmutableList.of(4.0, 8.0)) }));
}
Aggregations