Fix pull up lambda expression optimizer for regex_like and like function#21407
Merged
feilong-liu merged 1 commit intoprestodb:masterfrom Jan 4, 2024
Merged
Fix pull up lambda expression optimizer for regex_like and like function#21407feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu merged 1 commit intoprestodb:masterfrom
Conversation
59da6fa to
83bfcf7
Compare
83bfcf7 to
98fd1f7
Compare
jaystarshot
reviewed
Nov 27, 2023
Member
There was a problem hiding this comment.
Can this happen with other AbstractPrimitiveTypes which use some other java type?
Contributor
Author
There was a problem hiding this comment.
Update the code, instead of filter out Regex.class, use an allowlist of boolean, long, double, slice, block, which will cover most common types, including integer, bigint, varchar, map, array, boolean, row types etc.
Contributor
There was a problem hiding this comment.
But Joni regexp is a Slice in the backend right? Just making sure that usecase still works
Contributor
Author
There was a problem hiding this comment.
No, Joni regexp is has Regex as java type
jaystarshot
reviewed
Nov 27, 2023
Member
There was a problem hiding this comment.
Nit: The function can be better name, getUnderlyingRowExpressionForCast()
98fd1f7 to
15cd2c6
Compare
jaystarshot
approved these changes
Nov 30, 2023
kaikalur
approved these changes
Dec 19, 2023
pranjalssh
approved these changes
Jan 4, 2024
64 tasks
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.
Description
When the expression in a lambda function is of type JoniRegexType or LikePatternType (underlying Java type is Regex.class), do not extract this expression out. Instead, if it's a CAST(argument as JoniRegexType/LikePatternType), we are to extract the argument out if the argument is not of type JoniRegexType or LikePatternType
Motivation and Context
For a query like this
SELECT ANY_MATCH(a, x -> (x LIKE CONCAT('a', b))) AS rejected_by_control_model, FILTER(a, x -> x LIKE CONCAT('a', b)) FROM ( SELECT ARRAY[CAST(random() AS VARCHAR)] a, CAST(random() AS VARCHAR) AS b )", "values (false, array[]), pulling outCONCAT('a', b)will fail during bytecode generation, because of the underlying Regex data type.In this PR, I fixed it by not extracting expressions with these types.
Impact
Fix bug of the optimizer.
Test Plan
Added unit tests
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.