use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class TransformerTest method testTransformWithSelectorFilterWithStringBooleanValueOnStringColumn.
@Test
public void testTransformWithSelectorFilterWithStringBooleanValueOnStringColumn() {
final Transformer transformer = new Transformer(new TransformSpec(new SelectorDimFilter("dim", "false", null), null));
final InputRow row = new MapBasedInputRow(DateTimes.nowUtc(), ImmutableList.of("dim"), ImmutableMap.of("dim", "false"));
Assert.assertEquals(row, transformer.transform(row));
final InputRow row2 = new MapBasedInputRow(DateTimes.nowUtc(), ImmutableList.of("dim"), ImmutableMap.of("dim", "true"));
Assert.assertNull(transformer.transform(row2));
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryLeftWithFilterOnFactsUsingLookup.
@Test
public void test_makeCursors_factToCountryLeftWithFilterOnFactsUsingLookup() {
List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.LEFT));
Filter filter = new SelectorDimFilter("channel", "#de.wikipedia", null).toFilter();
JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(filter, joinableClauses, VirtualColumns.EMPTY);
JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(filter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { "Diskussion:Sebastian Schulz", "DE", "DE", "Germany" }));
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryInnerUsingCountryNumberUsingLookup.
@Test
public void test_makeCursors_factToCountryInnerUsingCountryNumberUsingLookup() {
// In non-SQL-compatible mode, we get an extra row, since the 'null' countryNumber for "Talk:Oswald Tilghman"
// is interpreted as 0 (a.k.a. Australia).
List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingNumberLookup(JoinType.INNER));
Filter filter = new SelectorDimFilter("channel", "#en.wikipedia", null).toFilter();
JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(filter, joinableClauses, VirtualColumns.EMPTY);
JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(filter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", FACT_TO_COUNTRY_ON_NUMBER_PREFIX + "v"), NullHandling.sqlCompatible() ? ImmutableList.of(new Object[] { "Peremptory norm", "AU", "Australia" }, new Object[] { "President of India", "US", "United States" }, new Object[] { "Glasgow", "GB", "United Kingdom" }, new Object[] { "Otjiwarongo Airport", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "Canada" }, new Object[] { "DirecTV", "US", "United States" }, new Object[] { "Carlo Curti", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "Italy" }, new Object[] { "Old Anatolian Turkish", "US", "United States" }, new Object[] { "Cream Soda", "SU", "States United" }, new Object[] { "History of Fourems", "MMMM", "Fourems" }) : ImmutableList.of(new Object[] { "Talk:Oswald Tilghman", null, "Australia" }, new Object[] { "Peremptory norm", "AU", "Australia" }, new Object[] { "President of India", "US", "United States" }, new Object[] { "Glasgow", "GB", "United Kingdom" }, new Object[] { "Otjiwarongo Airport", "US", "United States" }, new Object[] { "Sarah Michelle Gellar", "CA", "Canada" }, new Object[] { "DirecTV", "US", "United States" }, new Object[] { "Carlo Curti", "US", "United States" }, new Object[] { "Giusy Ferreri discography", "IT", "Italy" }, new Object[] { "Roma-Bangkok", "IT", "Italy" }, new Object[] { "Old Anatolian Turkish", "US", "United States" }, new Object[] { "Cream Soda", "SU", "States United" }, new Object[][] { new Object[] { "History of Fourems", "MMMM", "Fourems" } }));
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryRightWithFilterOnLeftIsNullUsingLookup.
@Test
public void test_makeCursors_factToCountryRightWithFilterOnLeftIsNullUsingLookup() {
List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.RIGHT));
Filter filter = new SelectorDimFilter("channel", null, null).toFilter();
JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(filter, joinableClauses, VirtualColumns.EMPTY);
JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis).makeCursors(filter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", "countryNumber", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of(new Object[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "AX", "Atlantis" }, new Object[] { null, null, NullHandling.sqlCompatible() ? null : 0L, "USCA", "Usca" }));
}
use of org.apache.druid.query.filter.SelectorDimFilter in project druid by druid-io.
the class HashJoinSegmentStorageAdapterTest method test_makeCursors_factToCountryInnerWithBaseFilter.
@Test
public void test_makeCursors_factToCountryInnerWithBaseFilter() {
final Filter baseFilter = Filters.or(Arrays.asList(new SelectorDimFilter("countryIsoCode", "CA", null).toFilter(), new SelectorDimFilter("countryIsoCode", "MatchNothing", null).toFilter()));
List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryOnIsoCode(JoinType.INNER));
JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(baseFilter, joinableClauses, VirtualColumns.EMPTY);
JoinTestHelper.verifyCursors(new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), baseFilter, joinableClauses, joinFilterPreAnalysis).makeCursors(null, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryIsoCode", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryNumber"), ImmutableList.of(new Object[] { "Didier Leclair", "CA", "CA", "Canada", 1L }, new Object[] { "Les Argonautes", "CA", "CA", "Canada", 1L }, new Object[] { "Sarah Michelle Gellar", "CA", "CA", "Canada", 1L }));
}
Aggregations