Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.metamx.common.StringUtils;
import io.druid.query.extraction.ExtractionFn;
import io.druid.query.lookup.LookupExtractionFn;
Expand Down Expand Up @@ -98,7 +99,12 @@ public DimFilter optimize()
{
if (this.getExtractionFn() instanceof LookupExtractionFn
&& ((LookupExtractionFn) this.getExtractionFn()).isOptimize()) {
LookupExtractor lookup = ((LookupExtractionFn) this.getExtractionFn()).getLookup();
// case ReplaceMissingValueWith matching the value we can not optimize
final LookupExtractionFn lookupExtractionFn = (LookupExtractionFn) this.getExtractionFn();
if (Strings.emptyToNull(lookupExtractionFn.getReplaceMissingValueWith()) == Strings.emptyToNull(value)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to leave out the emptyToNull() call on Strings.emptyToNull(lookupExtractionFn.getReplaceMissingValueWith(), since the constructor of FunctionalExtraction already does that:

  public FunctionalExtraction(
      final Function<String, String> extractionFunction,
      final boolean retainMissingValue,
      final String replaceMissingValueWith,
      final boolean injective
  )
  {
    this.retainMissingValue = retainMissingValue;
    this.replaceMissingValueWith = Strings.emptyToNull(replaceMissingValueWith);

return this;
}
final LookupExtractor lookup = lookupExtractionFn.getLookup();
final List<String> keys = lookup.unapply(this.getValue());
final String dimensionName = this.getDimension();
if (!keys.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public boolean isInjective()
@JsonProperty("optimize")
public boolean isOptimize()
{
return optimize;
// case retainMissingValue == true we can not optimize need to push down the filter
return !isRetainMissingValue() && optimize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b-slim I think this should be the in the optimize() call, it's the same kind of check as + if (Strings.emptyToNull(lookupExtractionFn.getReplaceMissingValueWith()) == Strings.emptyToNull(value)) { and I think that should go in the optimize() call itself

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to elaborate more, maybe it's possible to have some optimization with retainMissingValues=true in the future in some other use case, the current incompatibility of retainMissingValues and optimize() is specific to the ExtractionDimFilter optimization being used, so the check should go in the filter that's affected

}

@Override
Expand Down