Simplify bounds/range vs selectors/equality logic in SQL planning.#14619
Merged
gianm merged 2 commits intoapache:masterfrom Jul 20, 2023
Merged
Simplify bounds/range vs selectors/equality logic in SQL planning.#14619gianm merged 2 commits intoapache:masterfrom
gianm merged 2 commits intoapache:masterfrom
Conversation
1) Consolidate duplicate code related to Expressions#buildTimeFloorFilter. 2) Cleaner logic in Expressions#toSimpleLeafFilter: choose bounds vs range filter based solely on plannerContext.isUseBoundsAndSelectors, not also considering rhs kind. Use parsed rhs in both paths (except for numerics in the bound path). 3) Fix ArrayContains, ArrayOverlap to avoid equality filters when there is an extractionFn present. Fixes a bug introduced in apache#14612.
| stringVal = String.valueOf(RexLiteral.value(rhs)); | ||
| } else { | ||
| // Don't know how to filter on this kind of literal. | ||
| stringVal = String.valueOf(rhsParsed.getLiteralValue()); |
Member
There was a problem hiding this comment.
i wonder if we might want to check for ARRAY or COMPLEX types, since stringifying them and putting them in the filter isn't probably the right thing (it previously was impossible here because of the check for RexLiteral), could move
final ColumnType matchValueType = Calcites.getColumnTypeForRelDataType(rhs.getType());
outside of the range filter case and check matchValueType.isPrimitive() to be safe.
Contributor
Author
There was a problem hiding this comment.
Is it OK to filter on ARRAY or COMPLEX inside the range filter case? Or should we require primitive across the board?
Member
There was a problem hiding this comment.
totally cool for the range case since they include the ColumnType for the match value and know how to handle stuff, so just the bounds path needs guarded to not do weird stuff
clintropolis
approved these changes
Jul 19, 2023
gianm
added a commit
to gianm/druid
that referenced
this pull request
Jul 20, 2023
…pache#14619) * Simplify bounds/range vs selectors/equality logic in SQL planning. 1) Consolidate duplicate code related to Expressions#buildTimeFloorFilter. 2) Cleaner logic in Expressions#toSimpleLeafFilter: choose bounds vs range filter based solely on plannerContext.isUseBoundsAndSelectors, not also considering rhs kind. Use parsed rhs in both paths (except for numerics in the bound path). 3) Fix ArrayContains, ArrayOverlap to avoid equality filters when there is an extractionFn present. Fixes a bug introduced in apache#14612. * Avoid sending nonprimitives down the bound path.
abhishekagarwal87
pushed a commit
that referenced
this pull request
Jul 21, 2023
…14619) (#14624) * Simplify bounds/range vs selectors/equality logic in SQL planning. 1) Consolidate duplicate code related to Expressions#buildTimeFloorFilter. 2) Cleaner logic in Expressions#toSimpleLeafFilter: choose bounds vs range filter based solely on plannerContext.isUseBoundsAndSelectors, not also considering rhs kind. Use parsed rhs in both paths (except for numerics in the bound path). 3) Fix ArrayContains, ArrayOverlap to avoid equality filters when there is an extractionFn present. Fixes a bug introduced in #14612. * Avoid sending nonprimitives down the bound path.
sergioferragut
pushed a commit
to sergioferragut/druid
that referenced
this pull request
Jul 21, 2023
…pache#14619) * Simplify bounds/range vs selectors/equality logic in SQL planning. 1) Consolidate duplicate code related to Expressions#buildTimeFloorFilter. 2) Cleaner logic in Expressions#toSimpleLeafFilter: choose bounds vs range filter based solely on plannerContext.isUseBoundsAndSelectors, not also considering rhs kind. Use parsed rhs in both paths (except for numerics in the bound path). 3) Fix ArrayContains, ArrayOverlap to avoid equality filters when there is an extractionFn present. Fixes a bug introduced in apache#14612. * Avoid sending nonprimitives down the bound path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidate duplicate code related to Expressions#buildTimeFloorFilter.
Cleaner logic in Expressions#toSimpleLeafFilter: choose bounds vs range
filter based solely on plannerContext.isUseBoundsAndSelectors, not also
considering rhs kind. Use parsed rhs in both paths (except for numerics
in the bound path).
Fix ArrayContains, ArrayOverlap to avoid equality filters when there is
an extractionFn present. Fixes a bug introduced in remove extractionFn from equality, null, and range filters #14612.