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));
}
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 }));
}
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 }));
}
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 }));
}
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);
}
Aggregations