Support conjugates for scalar functions, add more scalar functions#8582
Support conjugates for scalar functions, add more scalar functions#8582Jackie-Jiang merged 15 commits intoapache:masterfrom
Conversation
be23f26 to
73d8d3d
Compare
|
GH issue: #8488 |
Codecov Report
@@ Coverage Diff @@
## master #8582 +/- ##
============================================
- Coverage 70.59% 68.92% -1.68%
- Complexity 4412 4413 +1
============================================
Files 1667 1669 +2
Lines 87314 87365 +51
Branches 13085 13098 +13
============================================
- Hits 61643 60218 -1425
- Misses 21411 22962 +1551
+ Partials 4260 4185 -75
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
eefad9f to
7a5fff1
Compare
Jackie-Jiang
left a comment
There was a problem hiding this comment.
This approach is better than #8563
Could you please add some description to the PR? Don't put the template as the description as that doesn't help reviewers understand the purpose of the PR
There was a problem hiding this comment.
(minor) Revert this file
There was a problem hiding this comment.
Suggest adding 3 execution nodes: AndExecutionNode, OrExecutionNode, NotExecutionNode. IMO no need to add the concept of ConjugateFunction
There was a problem hiding this comment.
User will mostly likely use the function name within the FilterKind, and we should include that in the alias
There was a problem hiding this comment.
Does svInt = 123 AND svInt < 123 work? Users usually don't use eq or lte explicitly.
Also let's put some filter that can potentially match record to test the behavior
There was a problem hiding this comment.
Is was LTE. Hence it worked :)
Had added these to be able to test and / or. Made the tests a bit more extensive.
All the filters actually match the record. SKIP_RECORD_KEY is being checked for.
612bcd7 to
e1c216e
Compare
There was a problem hiding this comment.
These 2 methods need to be annotated with nullableParameters = true
There was a problem hiding this comment.
(nit) Redundant parenthesis, same for others
| Boolean res = (Boolean) (executableNode.execute(row)); | |
| Boolean res = (Boolean) executableNode.execute(row); |
There was a problem hiding this comment.
We don't need to annotate the names because it matches the method name in the canonical format
There was a problem hiding this comment.
I wonder if users will use gt instead of >, and IIRC gt is not standard SQL syntax. We may just make the method name match the filter kind in camel case (they will be canonicalized to the same name)
There was a problem hiding this comment.
Let's change the expression to svInt = 123 AND svDouble <= 200. Users won't explicitly write query in this format
d48c94a to
70aae26
Compare
There was a problem hiding this comment.
need to make sure these work case-insensitive way (all other scalar functions do)
There was a problem hiding this comment.
This will work in a case insensitive way due to https://github.com/apache/pinot/blob/master/pinot-common/src/main/java/org/apache/pinot/common/request/context/FunctionContext.java#L42
Jackie-Jiang
left a comment
There was a problem hiding this comment.
LGTM, only minor/nit comments
There was a problem hiding this comment.
(minor)
| Preconditions.checkState(numArguments == 1, "Unsupported number of arguments for NOT operator"); | |
| Preconditions.checkState(numArguments == 1, "NOT function expects 1 argument, got: %s", numArguments); |
There was a problem hiding this comment.
(nit)
| return (Math.abs(a - b) >= DOUBLE_COMPARISON_TOLERANCE); | |
| return Math.abs(a - b) >= DOUBLE_COMPARISON_TOLERANCE; |
There was a problem hiding this comment.
(nit)
| return (Math.abs(a - b) < DOUBLE_COMPARISON_TOLERANCE); | |
| return Math.abs(a - b) < DOUBLE_COMPARISON_TOLERANCE; |
There was a problem hiding this comment.
(nit)
| return (val > a) && (val < b); | |
| return val > a && val < b; |
There was a problem hiding this comment.
(minor)
| public static boolean isNull(Object obj) { | |
| public static boolean isNull(@Nullable Object obj) { |
There was a problem hiding this comment.
(minor)
| public static boolean isNotNull(Object obj) { | |
| public static boolean isNotNull(@Nullable Object obj) { |
There was a problem hiding this comment.
this shouldn't work rt? it should be svInt == 123
There was a problem hiding this comment.
In SQL, we use = for comparison, e.g. SELECT * FROM myTable WHERE svInt = 123
ed6183a to
60d4227
Compare
60d4227 to
58739e4
Compare
This PR adds support for being able to use complex scalar function expressions for fitlterConfig. In addition to common comparison functions, support for AND, OR and NOT has been added.
GH issue: #8488
How to use
With this change, filterConfig's filterFunction can now be simple SQL like expressions. This simplifies filtering of records especially with Groovy expressions being disabled by default.