Search in sources :

Example 26 with SelectorDimFilter

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

the class LookupSerdeModuleTest method testExtractionFilterSere.

@Test
public void testExtractionFilterSere() throws Exception {
    final SelectorDimFilter filter = new SelectorDimFilter("xxx", "d", new RegisteredLookupExtractionFn(null, "beep", false, null, null, null));
    Assert.assertEquals(filter, objectMapper.readValue(objectMapper.writeValueAsBytes(filter), DimFilter.class));
}
Also used : SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) DimFilter(org.apache.druid.query.filter.DimFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Test(org.junit.Test)

Example 27 with SelectorDimFilter

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

the class CalciteJoinQueryTest method testInnerJoinOnTwoInlineDataSourcesWithOuterWhere_withLeftDirectAccess.

@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testInnerJoinOnTwoInlineDataSourcesWithOuterWhere_withLeftDirectAccess(Map<String, Object> queryContext) throws Exception {
    queryContext = withLeftDirectAccessEnabled(queryContext);
    testQuery("with abc as\n" + "(\n" + "  SELECT dim1, \"__time\", m1 from foo WHERE \"dim1\" = '10.1'\n" + ")\n" + "SELECT t1.dim1, t1.\"__time\" from abc as t1 INNER JOIN abc as t2 on t1.dim1 = t2.dim1 WHERE t1.dim1 = '10.1'\n", queryContext, ImmutableList.of(newScanQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new QueryDataSource(newScanQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(querySegmentSpec(Filtration.eternity())).filters(new SelectorDimFilter("dim1", "10.1", null)).columns(ImmutableList.of("dim1")).resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST).context(queryContext).build()), "j0.", equalsCondition(makeExpression("'10.1'"), makeColumnExpression("j0.dim1")), JoinType.INNER, selector("dim1", "10.1", null))).intervals(querySegmentSpec(Filtration.eternity())).virtualColumns(expressionVirtualColumn("v0", "\'10.1\'", ColumnType.STRING)).columns("__time", "v0").context(queryContext).build()), ImmutableList.of(new Object[] { "10.1", 946771200000L }));
}
Also used : GlobalTableDataSource(org.apache.druid.query.GlobalTableDataSource) TableDataSource(org.apache.druid.query.TableDataSource) QueryDataSource(org.apache.druid.query.QueryDataSource) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 28 with SelectorDimFilter

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

the class CalciteJoinQueryTest method testLeftJoinOnTwoInlineDataSources_withLeftDirectAccess.

@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testLeftJoinOnTwoInlineDataSources_withLeftDirectAccess(Map<String, Object> queryContext) throws Exception {
    queryContext = withLeftDirectAccessEnabled(queryContext);
    testQuery("with abc as\n" + "(\n" + "  SELECT dim1, \"__time\", m1 from foo WHERE \"dim1\" = '10.1'\n" + ")\n" + "SELECT t1.dim1, t1.\"__time\" from abc as t1 LEFT JOIN abc as t2 on t1.dim1 = t2.dim1\n", queryContext, ImmutableList.of(newScanQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new QueryDataSource(newScanQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(querySegmentSpec(Filtration.eternity())).filters(new SelectorDimFilter("dim1", "10.1", null)).columns(ImmutableList.of("dim1")).resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST).context(queryContext).build()), "j0.", equalsCondition(makeExpression("'10.1'"), makeColumnExpression("j0.dim1")), JoinType.LEFT, selector("dim1", "10.1", null))).intervals(querySegmentSpec(Filtration.eternity())).virtualColumns(expressionVirtualColumn("v0", "\'10.1\'", ColumnType.STRING)).columns("__time", "v0").context(queryContext).build()), ImmutableList.of(new Object[] { "10.1", 946771200000L }));
}
Also used : GlobalTableDataSource(org.apache.druid.query.GlobalTableDataSource) TableDataSource(org.apache.druid.query.TableDataSource) QueryDataSource(org.apache.druid.query.QueryDataSource) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 29 with SelectorDimFilter

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

the class CalciteJoinQueryTest method testLeftJoinOnTwoInlineDataSourcesWithOuterWhere_withLeftDirectAccess.

@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testLeftJoinOnTwoInlineDataSourcesWithOuterWhere_withLeftDirectAccess(Map<String, Object> queryContext) throws Exception {
    queryContext = withLeftDirectAccessEnabled(queryContext);
    testQuery("with abc as\n" + "(\n" + "  SELECT dim1, \"__time\", m1 from foo WHERE \"dim1\" = '10.1'\n" + ")\n" + "SELECT t1.dim1, t1.\"__time\" from abc as t1 LEFT JOIN abc as t2 on t1.dim1 = t2.dim1 WHERE t1.dim1 = '10.1'\n", queryContext, ImmutableList.of(newScanQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new QueryDataSource(newScanQueryBuilder().dataSource(CalciteTests.DATASOURCE1).intervals(querySegmentSpec(Filtration.eternity())).filters(new SelectorDimFilter("dim1", "10.1", null)).columns(ImmutableList.of("dim1")).resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST).context(queryContext).build()), "j0.", equalsCondition(makeExpression("'10.1'"), makeColumnExpression("j0.dim1")), JoinType.LEFT, selector("dim1", "10.1", null))).intervals(querySegmentSpec(Filtration.eternity())).virtualColumns(expressionVirtualColumn("v0", "\'10.1\'", ColumnType.STRING)).columns("__time", "v0").context(queryContext).build()), ImmutableList.of(new Object[] { "10.1", 946771200000L }));
}
Also used : GlobalTableDataSource(org.apache.druid.query.GlobalTableDataSource) TableDataSource(org.apache.druid.query.TableDataSource) QueryDataSource(org.apache.druid.query.QueryDataSource) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 30 with SelectorDimFilter

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

the class TimeseriesQueryRunnerTest method testTimeseriesWithInvertedFilterOnNonExistentDimension.

@Test
public void testTimeseriesWithInvertedFilterOnNonExistentDimension() {
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource(QueryRunnerTestHelper.DATA_SOURCE).granularity(QueryRunnerTestHelper.DAY_GRAN).filters(new NotDimFilter(new SelectorDimFilter("bobby", "sally", null))).intervals(QueryRunnerTestHelper.FIRST_TO_THIRD).aggregators(aggregatorFactoryList).postAggregators(QueryRunnerTestHelper.ADD_ROWS_INDEX_CONSTANT).descending(descending).context(makeContext()).build();
    List<Result<TimeseriesResultValue>> expectedResults = Arrays.asList(new Result<>(DateTimes.of("2011-04-01"), new TimeseriesResultValue(ImmutableMap.of("rows", 13L, "index", 6626.151596069336, "addRowsIndexConstant", 6640.151596069336, "uniques", QueryRunnerTestHelper.UNIQUES_9))), new Result<>(DateTimes.of("2011-04-02"), new TimeseriesResultValue(ImmutableMap.of("rows", 13L, "index", 5833.2095947265625, "addRowsIndexConstant", 5847.2095947265625, "uniques", QueryRunnerTestHelper.UNIQUES_9))));
    Iterable<Result<TimeseriesResultValue>> results = runner.run(QueryPlus.wrap(query)).toList();
    assertExpectedResults(expectedResults, results);
}
Also used : NotDimFilter(org.apache.druid.query.filter.NotDimFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) Result(org.apache.druid.query.Result) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)206 Test (org.junit.Test)184 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)78 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)54 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)41 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)39 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)37 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)34 ArrayList (java.util.ArrayList)29 Filter (org.apache.druid.query.filter.Filter)27 Result (org.apache.druid.query.Result)25 DimFilter (org.apache.druid.query.filter.DimFilter)24 InDimFilter (org.apache.druid.query.filter.InDimFilter)24 NotDimFilter (org.apache.druid.query.filter.NotDimFilter)24 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)23 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)22 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)22 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)21 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)20 HashMap (java.util.HashMap)19