Search in sources :

Example 6 with TableDataSource

use of org.apache.druid.query.TableDataSource in project druid by druid-io.

the class CalciteQueryTest method testGroupingWithNullInFilter.

@Test
public void testGroupingWithNullInFilter() throws Exception {
    // HashJoinSegmentStorageAdapter is not vectorizable
    cannotVectorize();
    testQuery("SELECT COUNT(*) FROM foo WHERE dim1 IN (NULL)", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(JoinDataSource.create(new TableDataSource(CalciteTests.DATASOURCE1), InlineDataSource.fromIterable(ImmutableList.of(new Object[] { null }), RowSignature.builder().add("ROW_VALUE", ColumnType.STRING).build()), "j0.", "(\"dim1\" == \"j0.ROW_VALUE\")", JoinType.INNER, null, ExprMacroTable.nil())).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).aggregators(aggregators(new CountAggregatorFactory("a0"))).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { 0L }));
}
Also used : TableDataSource(org.apache.druid.query.TableDataSource) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) Test(org.junit.Test)

Example 7 with TableDataSource

use of org.apache.druid.query.TableDataSource in project druid by druid-io.

the class LookupSegmentWranglerTest method test_getSegmentsForIntervals_nonLookup.

@Test
public void test_getSegmentsForIntervals_nonLookup() {
    expectedException.expect(ClassCastException.class);
    expectedException.expectMessage("TableDataSource cannot be cast");
    final Iterable<Segment> ignored = factory.getSegmentsForIntervals(new TableDataSource("foo"), Intervals.ONLY_ETERNITY);
}
Also used : TableDataSource(org.apache.druid.query.TableDataSource) LookupSegment(org.apache.druid.query.lookup.LookupSegment) LookupSegmentTest(org.apache.druid.query.lookup.LookupSegmentTest) Test(org.junit.Test)

Example 8 with TableDataSource

use of org.apache.druid.query.TableDataSource in project druid by druid-io.

the class InlineJoinableFactoryTest method testBuildNonInline.

@Test
public void testBuildNonInline() {
    expectedException.expect(ClassCastException.class);
    expectedException.expectMessage("TableDataSource cannot be cast");
    final Optional<Joinable> ignored = factory.build(new TableDataSource("foo"), makeCondition("x == \"j.y\""));
}
Also used : TableDataSource(org.apache.druid.query.TableDataSource) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) Test(org.junit.Test)

Example 9 with TableDataSource

use of org.apache.druid.query.TableDataSource in project druid by druid-io.

the class LookupJoinableFactoryTest method testBuildNonLookup.

@Test
public void testBuildNonLookup() {
    expectedException.expect(ClassCastException.class);
    expectedException.expectMessage("TableDataSource cannot be cast");
    final Optional<Joinable> ignored = factory.build(new TableDataSource("foo"), makeCondition("x == \"j.k\""));
}
Also used : TableDataSource(org.apache.druid.query.TableDataSource) LookupJoinable(org.apache.druid.segment.join.lookup.LookupJoinable) Test(org.junit.Test)

Example 10 with TableDataSource

use of org.apache.druid.query.TableDataSource in project druid by druid-io.

the class CalciteJoinQueryTest method testUnionAllTwoQueriesBothQueriesAreJoin.

@Test
public void testUnionAllTwoQueriesBothQueriesAreJoin() throws Exception {
    cannotVectorize();
    testQuery("(" + "SELECT COUNT(*) FROM foo LEFT JOIN lookup.lookyloo ON foo.dim1 = lookyloo.k " + "                               UNION ALL                                       " + "SELECT COUNT(*) FROM foo INNER JOIN lookup.lookyloo ON foo.dim1 = lookyloo.k" + ") ", ImmutableList.of(Druids.newTimeseriesQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim1"), makeColumnExpression("j0.k")), JoinType.LEFT)).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).aggregators(aggregators(new CountAggregatorFactory("a0"))).context(QUERY_CONTEXT_DEFAULT).build(), Druids.newTimeseriesQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new LookupDataSource("lookyloo"), "j0.", equalsCondition(makeColumnExpression("dim1"), makeColumnExpression("j0.k")), JoinType.INNER)).intervals(querySegmentSpec(Filtration.eternity())).granularity(Granularities.ALL).aggregators(aggregators(new CountAggregatorFactory("a0"))).context(QUERY_CONTEXT_DEFAULT).build()), ImmutableList.of(new Object[] { 6L }, new Object[] { 1L }));
}
Also used : GlobalTableDataSource(org.apache.druid.query.GlobalTableDataSource) TableDataSource(org.apache.druid.query.TableDataSource) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) LookupDataSource(org.apache.druid.query.LookupDataSource) Test(org.junit.Test)

Aggregations

TableDataSource (org.apache.druid.query.TableDataSource)118 Test (org.junit.Test)94 GlobalTableDataSource (org.apache.druid.query.GlobalTableDataSource)46 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)43 QueryDataSource (org.apache.druid.query.QueryDataSource)41 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)40 Parameters (junitparams.Parameters)30 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)19 LookupDataSource (org.apache.druid.query.LookupDataSource)18 DataSegment (org.apache.druid.timeline.DataSegment)15 Result (org.apache.druid.query.Result)14 CountDownLatch (java.util.concurrent.CountDownLatch)11 Query (org.apache.druid.query.Query)11 TimelineObjectHolder (org.apache.druid.timeline.TimelineObjectHolder)11 Interval (org.joda.time.Interval)11 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)10 ArrayList (java.util.ArrayList)9 GroupByQuery (org.apache.druid.query.groupby.GroupByQuery)9 ISE (org.apache.druid.java.util.common.ISE)8 SegmentDescriptor (org.apache.druid.query.SegmentDescriptor)8