use of org.apache.druid.query.LookupDataSource in project druid by druid-io.
the class JoinableFactoryWrapperTest method test_createSegmentMapFn_unusableClause.
@Test
public void test_createSegmentMapFn_unusableClause() {
final LookupDataSource lookupDataSource = new LookupDataSource("lookyloo");
final PreJoinableClause clause = new PreJoinableClause("j.", lookupDataSource, JoinType.LEFT, JoinConditionAnalysis.forExpression("x == \"j.x\"", "j.", ExprMacroTable.nil()));
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("dataSource is not joinable");
final Function<SegmentReference, SegmentReference> ignored = NOOP_JOINABLE_FACTORY_WRAPPER.createSegmentMapFn(null, ImmutableList.of(clause), new AtomicLong(), null);
}
use of org.apache.druid.query.LookupDataSource in project druid by druid-io.
the class CalciteJoinQueryTest method testFilterAndGroupByLookupUsingJoinOperator.
@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testFilterAndGroupByLookupUsingJoinOperator(Map<String, Object> queryContext) throws Exception {
// Cannot vectorize JOIN operator.
cannotVectorize();
testQuery("SELECT lookyloo.k, COUNT(*)\n" + "FROM foo LEFT JOIN lookup.lookyloo ON foo.dim2 = lookyloo.k\n" + "WHERE lookyloo.v = 'xa'\n" + "GROUP BY lookyloo.k", queryContext, ImmutableList.of(GroupByQuery.builder().setDataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim2"), makeColumnExpression("j0.k")), JoinType.LEFT)).setInterval(querySegmentSpec(Filtration.eternity())).setDimFilter(selector("j0.v", "xa", null)).setGranularity(Granularities.ALL).setDimensions(dimensions(new DefaultDimensionSpec("j0.k", "d0"))).setAggregatorSpecs(aggregators(new CountAggregatorFactory("a0"))).setContext(queryContext).build()), ImmutableList.of(new Object[] { "a", 2L }));
}
use of org.apache.druid.query.LookupDataSource in project druid by druid-io.
the class CalciteJoinQueryTest method testGroupByInnerJoinOnLookupUsingJoinOperator.
@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testGroupByInnerJoinOnLookupUsingJoinOperator(Map<String, Object> queryContext) throws Exception {
// Cannot vectorize JOIN operator.
cannotVectorize();
testQuery("SELECT lookyloo.v, COUNT(*)\n" + "FROM foo INNER JOIN lookup.lookyloo ON foo.dim1 = lookyloo.k\n" + "GROUP BY lookyloo.v", queryContext, ImmutableList.of(GroupByQuery.builder().setDataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim1"), makeColumnExpression("j0.k")), JoinType.INNER)).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setDimensions(dimensions(new DefaultDimensionSpec("j0.v", "d0"))).setAggregatorSpecs(aggregators(new CountAggregatorFactory("a0"))).setContext(queryContext).build()), ImmutableList.of(new Object[] { "xabc", 1L }));
}
use of org.apache.druid.query.LookupDataSource in project druid by druid-io.
the class CalciteJoinQueryTest method testFilterAndGroupByLookupUsingJoinOperatorWithNotFilter.
@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testFilterAndGroupByLookupUsingJoinOperatorWithNotFilter(Map<String, Object> queryContext) throws Exception {
// Cannot vectorize JOIN operator.
cannotVectorize();
testQuery("SELECT lookyloo.v, COUNT(*)\n" + "FROM foo LEFT JOIN lookup.lookyloo ON foo.dim2 = lookyloo.k\n" + "WHERE lookyloo.v <> 'xa'\n" + "GROUP BY lookyloo.v", queryContext, ImmutableList.of(GroupByQuery.builder().setDataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim2"), makeColumnExpression("j0.k")), JoinType.LEFT)).setInterval(querySegmentSpec(Filtration.eternity())).setDimFilter(not(selector("j0.v", "xa", null))).setGranularity(Granularities.ALL).setDimensions(dimensions(new DefaultDimensionSpec("j0.v", "d0"))).setAggregatorSpecs(aggregators(new CountAggregatorFactory("a0"))).setContext(queryContext).build()), ImmutableList.of(new Object[] { NULL_STRING, 3L }, new Object[] { "xabc", 1L }));
}
use of org.apache.druid.query.LookupDataSource in project druid by druid-io.
the class CalciteJoinQueryTest method testInnerJoinOnMultiValueColumn.
@Test
@Parameters(source = QueryContextForJoinProvider.class)
// regression test for https://github.com/apache/druid/issues/9924
@Ignore
public void testInnerJoinOnMultiValueColumn(Map<String, Object> queryContext) throws Exception {
cannotVectorize();
testQuery("SELECT dim3, l.v, count(*) from druid.foo f inner join lookup.lookyloo l on f.dim3 = l.k " + "group by 1, 2", queryContext, ImmutableList.of(GroupByQuery.builder().setDataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim3"), makeColumnExpression("j0.k")), JoinType.INNER)).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setAggregatorSpecs(aggregators(new CountAggregatorFactory("a0"))).setDimensions(dimensions(new DefaultDimensionSpec("dim3", "d0"), new DefaultDimensionSpec("j0.v", "d1"))).build()), ImmutableList.of(new Object[] { "2", "x2", 1L }));
}
Aggregations