use of org.apache.druid.query.filter.LikeDimFilter in project druid by druid-io.
the class CalciteJoinQueryTest method testUsingSubqueryAsPartOfOrFilter.
@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testUsingSubqueryAsPartOfOrFilter(Map<String, Object> queryContext) throws Exception {
// Cannot vectorize JOIN operator.
cannotVectorize();
testQuery("SELECT dim1, dim2, COUNT(*) FROM druid.foo\n" + "WHERE dim1 = 'xxx' OR dim2 IN (SELECT dim1 FROM druid.foo WHERE dim1 LIKE '%bc')\n" + "group by dim1, dim2 ORDER BY dim2", queryContext, ImmutableList.of(GroupByQuery.builder().setDataSource(join(join(new TableDataSource(CalciteTests.DATASOURCE1), new QueryDataSource(Druids.newTimeseriesQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(querySegmentSpec(Filtration.eternity())).filters(new LikeDimFilter("dim1", "%bc", null, null)).granularity(Granularities.ALL).aggregators(new CountAggregatorFactory("a0")).context(QUERY_CONTEXT_DEFAULT).build()), "j0.", "1", JoinType.INNER), new QueryDataSource(GroupByQuery.builder().setDataSource(CalciteTests.DATASOURCE1).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setVirtualColumns(expressionVirtualColumn("v0", "1", ColumnType.LONG)).setDimFilter(new LikeDimFilter("dim1", "%bc", null, null)).setDimensions(dimensions(new DefaultDimensionSpec("dim1", "d0"), new DefaultDimensionSpec("v0", "d1", ColumnType.LONG))).setContext(queryContext).build()), "_j0.", equalsCondition(makeColumnExpression("dim2"), makeColumnExpression("_j0.d0")), JoinType.LEFT)).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setDimFilter(or(selector("dim1", "xxx", null), and(not(selector("j0.a0", "0", null)), not(selector("_j0.d1", null, null)), not(selector("dim2", null, null))))).setDimensions(dimensions(new DefaultDimensionSpec("dim1", "d0"), new DefaultDimensionSpec("dim2", "d1"))).setAggregatorSpecs(aggregators(new CountAggregatorFactory("a0"))).setLimitSpec(new DefaultLimitSpec(ImmutableList.of(new OrderByColumnSpec("d1", OrderByColumnSpec.Direction.ASCENDING)), Integer.MAX_VALUE)).setContext(queryContext).build()), ImmutableList.of(new Object[] { "def", "abc", 1L }));
}
Aggregations