-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add long/float ColumnSelectorStrategy implementations #3838
Changes from 1 commit
b67e83e
95e2e50
b783bb8
b5fa6c4
81d7c73
3a3be44
c1c1756
d5836c1
4633025
07dc601
e529570
3fb908e
d6f6384
f0c3f5b
b5aef87
e5bca4a
299e13f
ab813bc
3e0ff60
5b5f385
b5dad54
3e993ee
bfd6c8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import io.druid.java.util.common.guava.Sequence; | ||
import io.druid.java.util.common.guava.Sequences; | ||
import io.druid.query.QueryInterruptedException; | ||
import io.druid.query.dimension.BaseFilteredDimensionSpec; | ||
import io.druid.query.dimension.DimensionSpec; | ||
import io.druid.query.extraction.ExtractionFn; | ||
import io.druid.query.filter.BooleanFilter; | ||
|
@@ -455,10 +456,17 @@ private DimensionSelector makeDimensionSelectorUndecorated( | |
} | ||
|
||
if (columnDesc.getCapabilities().getType() == ValueType.LONG) { | ||
// Filtered dimension specs are not supported on numerics | ||
if (dimensionSpec instanceof BaseFilteredDimensionSpec) { | ||
return NullDimensionSelector.instance(); | ||
} | ||
return new LongWrappingDimensionSelector(makeLongColumnSelector(dimension), extractionFn); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to create a bad selector if extractionFn is null. Consider modifying LongWrappingDimensionSelector and FloatWrappingDimensionSelector to do something sensible even if extractionFn is null. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, why didn't tests catch this? Is there a missing test case, or is there some reason why this method won't ever get called with a null extractionFn? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only case these would get created is if a query has a dimension spec on a base numeric column but with an extractionFn applied, so exFn was never null |
||
} | ||
|
||
if (columnDesc.getCapabilities().getType() == ValueType.FLOAT) { | ||
if (dimensionSpec instanceof BaseFilteredDimensionSpec) { | ||
return NullDimensionSelector.instance(); | ||
} | ||
return new FloatWrappingDimensionSelector(makeFloatColumnSelector(dimension), extractionFn); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import io.druid.java.util.common.guava.Sequence; | ||
import io.druid.java.util.common.guava.Sequences; | ||
import io.druid.query.QueryInterruptedException; | ||
import io.druid.query.dimension.BaseFilteredDimensionSpec; | ||
import io.druid.query.dimension.DefaultDimensionSpec; | ||
import io.druid.query.dimension.DimensionSpec; | ||
import io.druid.query.extraction.ExtractionFn; | ||
|
@@ -359,9 +360,16 @@ public DimensionSelector makeDimensionSelector( | |
ColumnCapabilities capabilities = getColumnCapabilities(dimension); | ||
if (capabilities != null) { | ||
if (capabilities.getType() == ValueType.LONG) { | ||
if (dimensionSpec instanceof BaseFilteredDimensionSpec) { | ||
// Filtered dimension specs are not supported on numerics | ||
return dimensionSpec.decorate(NullDimensionSelector.instance()); | ||
} | ||
return new LongWrappingDimensionSelector(makeLongColumnSelector(dimension), extractionFn); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar issues to QueryableIndexStorageAdapter with null extractionFns. |
||
} | ||
if (capabilities.getType() == ValueType.FLOAT) { | ||
if (dimensionSpec instanceof BaseFilteredDimensionSpec) { | ||
return dimensionSpec.decorate(NullDimensionSelector.instance()); | ||
} | ||
return new FloatWrappingDimensionSelector(makeFloatColumnSelector(dimension), extractionFn); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, these
instanceof BaseFilteredDimensionSpec
checks everywhere are kind of gnarly. There's way too many of them for comfort. Is there something better we can do? Maybe making them work is a better option if it's not too hard… why don't they, again? They should be able to decorate a wrapped dimension selector just fine, right?Is it just that we don't know if a DimensionSpec's "decorate" method is actually going to get called, because getColumnValueSelectorFromDimensionSpec might skip it by going and making something like a LongColumnSelector instead? If so, we could address that by adding a "mustDecorate" method to DimensionSpec, and if it mustDecorate, then we force creation of a DimensionSelector (rather than whatever type the underlying column is).
I would also accept alternate solutions that don't involve instanceof checks all over the place.