Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io.druid.java.util.common.IAE;
import io.druid.data.input.impl.DimensionSchema.MultiValueHandling;
import io.druid.segment.column.Column;
import io.druid.segment.column.ColumnCapabilities;
import io.druid.segment.column.ValueType;

Expand All @@ -35,6 +36,11 @@ public static DimensionHandler getHandlerFromCapabilities(
)
{
DimensionHandler handler = null;

if (dimensionName.equals(Column.TIME_COLUMN_NAME)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a reminder that this logic probably needs to change with new dim typing work?

return new StringDimensionHandler(dimensionName, MultiValueHandling.ARRAY);
}

if (capabilities.getType() == ValueType.STRING) {
if (!capabilities.isDictionaryEncoded() || !capabilities.hasBitmapIndexes()) {
throw new IAE("String column must have dictionary encoding and bitmap index.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6195,4 +6195,227 @@ public void testGroupByCardinalityAggWithExtractionFn()
Iterable<Row> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
TestHelper.assertExpectedObjects(expectedResults, results, "");
}

@Test
public void testGroupByTimeExtractionNamedUnderUnderTime()
{
GroupByQuery query = GroupByQuery
.builder()
.setDataSource(QueryRunnerTestHelper.dataSource)
.setQuerySegmentSpec(QueryRunnerTestHelper.fullOnInterval)
.setDimensions(
Lists.newArrayList(
new DefaultDimensionSpec("market", "market"),
new ExtractionDimensionSpec(
Column.TIME_COLUMN_NAME,
Column.TIME_COLUMN_NAME,
new TimeFormatExtractionFn("EEEE", null, null, null),
null
)
)
)
.setAggregatorSpecs(
Arrays.asList(
QueryRunnerTestHelper.rowsCount,
QueryRunnerTestHelper.indexDoubleSum
)
)
.setPostAggregatorSpecs(Arrays.<PostAggregator>asList(QueryRunnerTestHelper.addRowsIndexConstant))
.setGranularity(QueryRunnerTestHelper.allGran)
.setDimFilter(
new OrDimFilter(
Arrays.<DimFilter>asList(
new SelectorDimFilter("market", "spot", null),
new SelectorDimFilter("market", "upfront", null)
)
)
)
.build();
List<Row> expectedResults = Arrays.asList(
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Friday",
"market",
"spot",
"index",
13219.574157714844,
"rows",
117L,
"addRowsIndexConstant",
13337.574157714844
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Monday",
"market",
"spot",
"index",
13557.738830566406,
"rows",
117L,
"addRowsIndexConstant",
13675.738830566406
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Saturday",
"market",
"spot",
"index",
13493.751281738281,
"rows",
117L,
"addRowsIndexConstant",
13611.751281738281
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Sunday",
"market",
"spot",
"index",
13585.541015625,
"rows",
117L,
"addRowsIndexConstant",
13703.541015625
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Thursday",
"market",
"spot",
"index",
14279.127197265625,
"rows",
126L,
"addRowsIndexConstant",
14406.127197265625
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Tuesday",
"market",
"spot",
"index",
13199.471435546875,
"rows",
117L,
"addRowsIndexConstant",
13317.471435546875
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Wednesday",
"market",
"spot",
"index",
14271.368591308594,
"rows",
126L,
"addRowsIndexConstant",
14398.368591308594
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Friday",
"market",
"upfront",
"index",
27297.8623046875,
"rows",
26L,
"addRowsIndexConstant",
27324.8623046875
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Monday",
"market",
"upfront",
"index",
27619.58447265625,
"rows",
26L,
"addRowsIndexConstant",
27646.58447265625
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Saturday",
"market",
"upfront",
"index",
27820.83154296875,
"rows",
26L,
"addRowsIndexConstant",
27847.83154296875
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Sunday",
"market",
"upfront",
"index",
24791.223876953125,
"rows",
26L,
"addRowsIndexConstant",
24818.223876953125
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Thursday",
"market",
"upfront",
"index",
28562.748901367188,
"rows",
28L,
"addRowsIndexConstant",
28591.748901367188
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Tuesday",
"market",
"upfront",
"index",
26968.280639648438,
"rows",
26L,
"addRowsIndexConstant",
26995.280639648438
),
GroupByQueryRunnerTestHelper.createExpectedRow(
"1970-01-01",
"__time",
"Wednesday",
"market",
"upfront",
"index",
28985.5751953125,
"rows",
28L,
"addRowsIndexConstant",
29014.5751953125
)
);
Iterable<Row> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
TestHelper.assertExpectedObjects(expectedResults, results, "");
}
}