use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testAlphaNumericMatchNull.
@Test
public void testAlphaNumericMatchNull() {
assertFilterMatches(new BoundDimFilter("dim0", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim1", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0"));
if (NullHandling.replaceWithDefault()) {
assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "2", "5"));
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
} else {
assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("2"));
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
}
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testRequiredColumnRewrite.
@Test
public void testRequiredColumnRewrite() {
BoundFilter filter = new BoundFilter(new BoundDimFilter("dim0", "", "", false, false, true, null, StringComparators.ALPHANUMERIC));
BoundFilter filter2 = new BoundFilter(new BoundDimFilter("dim1", "", "", false, false, true, null, StringComparators.ALPHANUMERIC));
Assert.assertTrue(filter.supportsRequiredColumnRewrite());
Assert.assertTrue(filter2.supportsRequiredColumnRewrite());
Filter rewrittenFilter = filter.rewriteRequiredColumns(ImmutableMap.of("dim0", "dim1"));
Assert.assertEquals(filter2, rewrittenFilter);
expectedException.expect(IAE.class);
expectedException.expectMessage("Received a non-applicable rewrite: {invalidName=dim1}, filter's dimension: dim0");
filter.rewriteRequiredColumns(ImmutableMap.of("invalidName", "dim1"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testLexicographicMatchMissingColumn.
@Test
public void testLexicographicMatchMissingColumn() {
if (NullHandling.replaceWithDefault()) {
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
assertFilterMatches(new BoundDimFilter("dim3", "", null, false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
} else {
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim3", "", null, false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
}
assertFilterMatches(new BoundDimFilter("dim3", "", "", true, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim3", null, "", false, false, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
if (NullHandling.sqlCompatible()) {
assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
} else {
assertFilterMatches(new BoundDimFilter("dim3", null, "", false, true, false, null, StringComparators.LEXICOGRAPHIC), ImmutableList.of());
}
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testAlphaNumericMatchWithNegatives.
@Test
public void testAlphaNumericMatchWithNegatives() {
assertFilterMatches(new BoundDimFilter("dim1", "-2000", "3", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim1", "3", "-2000", true, true, true, null, StringComparators.ALPHANUMERIC), ImmutableList.of("1", "6", "7"));
}
use of org.apache.druid.query.filter.BoundDimFilter in project druid by druid-io.
the class BoundFilterTest method testNumericMatchNull.
@Test
public void testNumericMatchNull() {
assertFilterMatches(new BoundDimFilter("dim0", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of());
assertFilterMatches(new BoundDimFilter("dim1", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("0"));
if (NullHandling.replaceWithDefault()) {
assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("1", "2", "5"));
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("0", "1", "2", "3", "4", "5", "6", "7"));
} else {
assertFilterMatches(new BoundDimFilter("dim2", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of("2"));
assertFilterMatches(new BoundDimFilter("dim3", "", "", false, false, false, null, StringComparators.NUMERIC), ImmutableList.of());
}
}
Aggregations