Repository navigation
Match Spark semantics for endsWith filters on values with a trailing newline - #157
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
…newline
The pushed down StringEndsWith regex ended with $, which in MongoDB
regular expressions also matches before a final newline. Values such as
"abc\n" were returned for endsWith("abc") even though Spark does not
reapply pushed filters. Anchor the pattern with \z instead.
Contributor
|
hi @RaphaelFakhri thanks for opening the PR we will take a look at it next week |
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.
Summary
ExpressionConvertertranslatesStringEndsWithinto the regular expression.*\Q<value>\E$. In MongoDB regular expressions,$also matches before a final newline, so a value such as"abc\n"matchesendsWith("abc"). Spark treats pushed filters as fully applied and does not filter those rows again, so the result differs from Spark semantics.This change anchors the pattern with
\z, which matches only at the absolute end of the string.Changes
ExpressionConverter: use\zinstead of$forStringEndsWith.MongoBatchTest#testReadsFiltersMatchLiterals: addline_endandline_end\ndocuments and anendsWith("line_end")case that expects onlyline_end.Testing
line_end\nis returned).MongoBatchTestpass against MongoDB 7.0.14.spotlessCheck,checkstyleMainandcheckstyleIntegrationTestpass.