use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.
the class LookupExtractionFnTest method testCacheKey.
@Test
public void testCacheKey() {
if (retainMissing && !NullHandling.isNullOrEquivalent(replaceMissing)) {
// skip
return;
}
final Map<String, String> weirdMap = new HashMap<>();
weirdMap.put("foobar", null);
final LookupExtractionFn lookupExtractionFn = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("foo", "bar"), false), retainMissing, replaceMissing, injective, false);
if (NullHandling.isNullOrEquivalent(replaceMissing) || retainMissing) {
Assert.assertFalse(Arrays.equals(lookupExtractionFn.getCacheKey(), new LookupExtractionFn(lookupExtractionFn.getLookup(), !lookupExtractionFn.isRetainMissingValue(), lookupExtractionFn.getReplaceMissingValueWith(), lookupExtractionFn.isInjective(), false).getCacheKey()));
Assert.assertFalse(Arrays.equals(lookupExtractionFn.getCacheKey(), new LookupExtractionFn(lookupExtractionFn.getLookup(), !lookupExtractionFn.isRetainMissingValue(), lookupExtractionFn.getReplaceMissingValueWith(), !lookupExtractionFn.isInjective(), false).getCacheKey()));
}
Assert.assertFalse(Arrays.equals(lookupExtractionFn.getCacheKey(), new LookupExtractionFn(new MapLookupExtractor(weirdMap, false), lookupExtractionFn.isRetainMissingValue(), lookupExtractionFn.getReplaceMissingValueWith(), lookupExtractionFn.isInjective(), false).getCacheKey()));
Assert.assertFalse(Arrays.equals(lookupExtractionFn.getCacheKey(), new LookupExtractionFn(lookupExtractionFn.getLookup(), lookupExtractionFn.isRetainMissingValue(), lookupExtractionFn.getReplaceMissingValueWith(), !lookupExtractionFn.isInjective(), false).getCacheKey()));
}
use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.
the class LookupExtractionFnTest method testEqualsAndHash.
@Test
public void testEqualsAndHash() {
if (retainMissing && !NullHandling.isNullOrEquivalent(replaceMissing)) {
// skip
return;
}
final LookupExtractionFn lookupExtractionFn1 = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("foo", "bar"), false), retainMissing, replaceMissing, injective, false);
final LookupExtractionFn lookupExtractionFn2 = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("foo", "bar"), false), retainMissing, replaceMissing, injective, false);
final LookupExtractionFn lookupExtractionFn3 = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("foo", "bar2"), false), retainMissing, replaceMissing, injective, false);
Assert.assertEquals(lookupExtractionFn1, lookupExtractionFn2);
Assert.assertEquals(lookupExtractionFn1.hashCode(), lookupExtractionFn2.hashCode());
Assert.assertNotEquals(lookupExtractionFn1, lookupExtractionFn3);
Assert.assertNotEquals(lookupExtractionFn1.hashCode(), lookupExtractionFn3.hashCode());
}
use of org.apache.druid.query.extraction.MapLookupExtractor in project druid by druid-io.
the class LookupExtractionFnExpectationsTest method testMissingKeyIsReplaced.
@Test
public void testMissingKeyIsReplaced() {
final LookupExtractionFn lookupExtractionFn = new LookupExtractionFn(new MapLookupExtractor(ImmutableMap.of("foo", "bar"), false), false, "REPLACE", false, false);
Assert.assertEquals("REPLACE", lookupExtractionFn.apply(null));
}
Aggregations