use of org.apache.druid.query.extraction.StringFormatExtractionFn in project druid by druid-io.
the class TopNQueryRunnerTest method testTopNOnMissingColumnWithExtractionFn.
@Test
public void testTopNOnMissingColumnWithExtractionFn() {
TopNQuery query = new TopNQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(QueryRunnerTestHelper.ALL_GRAN).dimension(new ExtractionDimensionSpec("nonexistentColumn", "alias", new StringFormatExtractionFn("theValue"))).metric("rows").threshold(4).intervals(QueryRunnerTestHelper.FULL_ON_INTERVAL_SPEC).aggregators(new CountAggregatorFactory("rows")).build();
List<Result<TopNResultValue>> expectedResults = Collections.singletonList(new Result<>(DateTimes.of("2011-01-12T00:00:00.000Z"), new TopNResultValue(Collections.<Map<String, Object>>singletonList(ImmutableMap.<String, Object>builder().put("alias", "theValue").put("rows", 1209L).build()))));
assertExpectedResults(expectedResults, query);
}
use of org.apache.druid.query.extraction.StringFormatExtractionFn in project druid by druid-io.
the class GroupByQueryRunnerTest method testGroupByOnMissingColumn.
@Test
public void testGroupByOnMissingColumn() {
// Cannot vectorize due to extraction dimension spec.
cannotVectorize();
GroupByQuery query = makeQueryBuilder().setDataSource(QueryRunnerTestHelper.DATA_SOURCE).setQuerySegmentSpec(QueryRunnerTestHelper.FIRST_TO_THIRD).setDimensions(new DefaultDimensionSpec("nonexistent0", "alias0"), new ExtractionDimensionSpec("nonexistent1", "alias1", new StringFormatExtractionFn("foo"))).setAggregatorSpecs(QueryRunnerTestHelper.ROWS_COUNT).setGranularity(QueryRunnerTestHelper.ALL_GRAN).build();
List<ResultRow> expectedResults = Collections.singletonList(makeRow(query, "2011-04-01", "alias0", null, "alias1", "foo", "rows", 26L));
Iterable<ResultRow> results = GroupByQueryRunnerTestHelper.runQuery(factory, runner, query);
TestHelper.assertExpectedObjects(expectedResults, results, "missing-column");
}
Aggregations