use of io.druid.query.lookup.RegisteredLookupExtractionFn in project druid by druid-io.
the class CalciteQueryTest method testFilterAndGroupByLookup.
@Test
public void testFilterAndGroupByLookup() throws Exception {
final RegisteredLookupExtractionFn extractionFn = new RegisteredLookupExtractionFn(null, "lookyloo", false, null, false, true);
testQuery("SELECT LOOKUP(dim1, 'lookyloo'), COUNT(*) FROM foo\n" + "WHERE LOOKUP(dim1, 'lookyloo') <> 'xxx'\n" + "GROUP BY LOOKUP(dim1, 'lookyloo')", ImmutableList.<Query>of(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE1).setInterval(QSS(Filtration.eternity())).setGranularity(Granularities.ALL).setDimFilter(NOT(SELECTOR("dim1", "xxx", extractionFn))).setDimensions(DIMS(new ExtractionDimensionSpec("dim1", "d0", ValueType.STRING, extractionFn))).setAggregatorSpecs(AGGS(new CountAggregatorFactory("a0"))).setContext(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { "", 5L }, new Object[] { "xabc", 1L }));
}
use of io.druid.query.lookup.RegisteredLookupExtractionFn in project druid by druid-io.
the class LookupExtractionOperator method convert.
@Override
public RowExtraction convert(final DruidOperatorTable operatorTable, final PlannerContext plannerContext, final List<String> rowOrder, final RexNode expression) {
final RexCall call = (RexCall) expression;
final RowExtraction rex = Expressions.toRowExtraction(operatorTable, plannerContext, rowOrder, call.getOperands().get(0));
if (rex == null) {
return null;
}
final String lookupName = RexLiteral.stringValue(call.getOperands().get(1));
final RegisteredLookupExtractionFn extractionFn = new RegisteredLookupExtractionFn(lookupReferencesManager, lookupName, false, null, false, true);
return RowExtraction.of(rex.getColumn(), ExtractionFns.compose(extractionFn, rex.getExtractionFn()));
}
use of io.druid.query.lookup.RegisteredLookupExtractionFn in project druid by druid-io.
the class CalciteQueryTest method testCountDistinctOfLookup.
@Test
public void testCountDistinctOfLookup() throws Exception {
final RegisteredLookupExtractionFn extractionFn = new RegisteredLookupExtractionFn(null, "lookyloo", false, null, false, true);
testQuery("SELECT COUNT(DISTINCT LOOKUP(dim1, 'lookyloo')) FROM foo", ImmutableList.<Query>of(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(QSS(Filtration.eternity())).granularity(Granularities.ALL).aggregators(AGGS(new CardinalityAggregatorFactory("a0", ImmutableList.<DimensionSpec>of(new ExtractionDimensionSpec("dim1", null, extractionFn)), false))).context(TIMESERIES_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { 2L }));
}
Aggregations