use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class FilteredAggregatorTest method testAggregateWithNotFilter.
@Test
public void testAggregateWithNotFilter() {
final float[] values = { 0.15f, 0.27f };
final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
FilteredAggregatorFactory factory = new FilteredAggregatorFactory(new DoubleSumAggregatorFactory("billy", "value"), new NotDimFilter(new SelectorDimFilter("dim", "b", null)));
validateFilteredAggs(factory, values, selector);
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class FilteredAggregatorTest method testAggregateWithAndFilter.
@Test
public void testAggregateWithAndFilter() {
final float[] values = { 0.15f, 0.27f };
final TestFloatColumnSelector selector = new TestFloatColumnSelector(values);
FilteredAggregatorFactory factory = new FilteredAggregatorFactory(new DoubleSumAggregatorFactory("billy", "value"), new AndDimFilter(Lists.newArrayList(new NotDimFilter(new SelectorDimFilter("dim", "b", null)), new SelectorDimFilter("dim", "a", null))));
validateFilteredAggs(factory, values, selector);
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class ConvertBoundsToSelectors method process.
@Override
public DimFilter process(DimFilter filter) {
if (filter instanceof BoundDimFilter) {
final BoundDimFilter bound = (BoundDimFilter) filter;
final StringComparator comparator = RowSignatures.getNaturalStringComparator(rowSignature, SimpleExtraction.of(bound.getDimension(), bound.getExtractionFn()));
if (bound.hasUpperBound() && bound.hasLowerBound() && bound.getUpper().equals(bound.getLower()) && !bound.isUpperStrict() && !bound.isLowerStrict() && bound.getOrdering().equals(comparator)) {
return new SelectorDimFilter(bound.getDimension(), bound.getUpper(), bound.getExtractionFn());
} else {
return filter;
}
} else {
return filter;
}
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class DatasourceIngestionSpecTest method testMultiIntervalSerde.
@Test
public void testMultiIntervalSerde() throws Exception {
// defaults
String jsonStr = "{\n" + " \"dataSource\": \"test\",\n" + " \"intervals\": [\"2014/2015\", \"2016/2017\"]\n" + "}\n";
DatasourceIngestionSpec actual = MAPPER.readValue(MAPPER.writeValueAsString(MAPPER.readValue(jsonStr, DatasourceIngestionSpec.class)), DatasourceIngestionSpec.class);
List<Interval> intervals = ImmutableList.of(Intervals.of("2014/2015"), Intervals.of("2016/2017"));
DatasourceIngestionSpec expected = new DatasourceIngestionSpec("test", null, intervals, null, null, null, null, false, null);
Assert.assertEquals(expected, actual);
// non-defaults
jsonStr = "{\n" + " \"dataSource\": \"test\",\n" + " \"intervals\": [\"2014/2015\", \"2016/2017\"],\n" + " \"segments\": [{\n" + " \"dataSource\":\"test\",\n" + " \"interval\":\"2014-01-01T00:00:00.000Z/2017-01-01T00:00:00.000Z\",\n" + " \"version\":\"v0\",\n" + " \"loadSpec\":null,\n" + " \"dimensions\":\"\",\n" + " \"metrics\":\"\",\n" + " \"shardSpec\":{\"type\":\"none\"},\n" + " \"binaryVersion\":9,\n" + " \"size\":128,\n" + " \"identifier\":\"test_2014-01-01T00:00:00.000Z_2017-01-01T00:00:00.000Z_v0\"\n" + " }],\n" + " \"filter\": { \"type\": \"selector\", \"dimension\": \"dim\", \"value\": \"value\"},\n" + " \"granularity\": \"day\",\n" + " \"dimensions\": [\"d1\", \"d2\"],\n" + " \"metrics\": [\"m1\", \"m2\", \"m3\"],\n" + " \"ignoreWhenNoSegments\": true\n" + "}\n";
expected = new DatasourceIngestionSpec("test", null, intervals, ImmutableList.of(new DataSegment("test", Intervals.of("2014/2017"), "v0", null, null, null, null, 9, 128)), new SelectorDimFilter("dim", "value", null), Lists.newArrayList("d1", "d2"), Lists.newArrayList("m1", "m2", "m3"), true, null);
actual = MAPPER.readValue(MAPPER.writeValueAsString(MAPPER.readValue(jsonStr, DatasourceIngestionSpec.class)), DatasourceIngestionSpec.class);
Assert.assertEquals(expected, actual);
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class DatasourceIngestionSpecTest method testSingleIntervalSerde.
@Test
public void testSingleIntervalSerde() throws Exception {
Interval interval = Intervals.of("2014/2015");
DatasourceIngestionSpec expected = new DatasourceIngestionSpec("test", interval, null, null, new SelectorDimFilter("dim", "value", null), Lists.newArrayList("d1", "d2"), Lists.newArrayList("m1", "m2", "m3"), false, null);
DatasourceIngestionSpec actual = MAPPER.readValue(MAPPER.writeValueAsString(expected), DatasourceIngestionSpec.class);
Assert.assertEquals(ImmutableList.of(interval), actual.getIntervals());
Assert.assertEquals(expected, actual);
}
Aggregations