Repository navigation
Remove duplicates from IN-list before turning it to an ExplodeExpression - #3608
Merged
hazefully merged 4 commits intoSep 23, 2025
Merged
Conversation
This commit makes use of the new wrapper value introduced in 4.5.10.0, ArrayDistinctValue, to remove duplicate values from the list provided to an IN predicate in SQL before transforming the IN predicate to an ExplodeExpression. This prevents duplicate result values if the planner ends up implementing the query graph as a nested loop join between the ExplodeExpression of the IN list and the left operand of the IN predicate. This is a breaking change that is not compatible with versions of fdb-record-layer < 4.5.10.0.
hazefully
force-pushed
the
fix-in-predicate-duplicates-in-sql
branch
from
September 18, 2025 15:49
cab55f1 to
8d28bd5
Compare
hazefully
commented
Sep 18, 2025
| # TODO TODO (IN expansion in cascades planner should distinct the in-list to avoid duplicates) | ||
| # LONG value matched against IN list of repeated LONG values | ||
| - query: select a, b from ta where b in (1, 1, 1, 1) | ||
| - explain: "ISCAN(F1 <,>) | FLATMAP q0 -> { EXPLODE arrayDistinct(promote(@c10 AS ARRAY(LONG))) | FILTER q0.B EQUALS _ AS q1 RETURN (q0.A AS A, q0.B AS B) }" |
Contributor
Author
There was a problem hiding this comment.
I added an explain here and to the other tests checking duplicates since the duplicate bug only happens with nested loop joins, so if anything changes the planning the assumption these tests make about old versions will be incorrect.
hazefully
marked this pull request as ready for review
September 18, 2025 15:50
normen662
requested changes
Sep 22, 2025
| - explain: "ISCAN(F1 <,>) | FLATMAP q0 -> { EXPLODE arrayDistinct(promote(@c10 AS ARRAY(LONG))) | FILTER q0.B EQUALS _ AS q1 RETURN (q0.A AS A, q0.B AS B) }" | ||
| - initialVersionLessThan: !current_version | ||
| - unorderedResult: [{A: 6, 3}, {A: 7, 2}, {A: 8, 1}, {A: 8, 1}] | ||
| # IN expansion in cascades planner distincts the in-list since this version preventing duplicate results with nested loop joins |
Contributor
There was a problem hiding this comment.
You don't have to leave a comment why a thing now works the way it should have worked from the beginning. Maybe you can rewrite these comments in a way that they explain why the old results are in fact the wrong results, instead of explaining why the new result is the new result :-)
normen662
approved these changes
Sep 22, 2025
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.
This PR makes use of the new wrapper value introduced in 4.5.10.0,
ArrayDistinctValue, to remove duplicate values from the list provided to an IN predicate in SQL before transforming the IN predicate to an ExplodeExpression. This prevents duplicate result values if the planner ends up implementing the query graph as a nested loop join between the ExplodeExpression of the IN list and the left operand of the IN predicate.Note: This is a breaking change that is not compatible with versions of
fdb-record-layer< 4.5.10.0.Fixes #3559.