Add isnotempty PPL function#5193
Conversation
PR Reviewer Guide 🔍(Review updated until commit 5eed3f2)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 5eed3f2 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 0ecc7f1
Suggestions up to commit 88cfad4
|
88cfad4 to
0ecc7f1
Compare
|
Persistent review updated to latest commit 0ecc7f1 |
There was a problem hiding this comment.
Overall solid, nice work. Good call on just registering this as an inversion of the existing function.
One chore to fix before this can be merged (in general we're gonna need green CI).
Ideally this could use a unit test, but doctest & existing isempty tests mostly covers everything we care about.
BWC tests failing due to flaky network issues, will just rerun them if they still fail once everything else is green.
|
|
||
| ```ppl | ||
| source=accounts | ||
| | eval temp = ifnull(employer, ' ') |
There was a problem hiding this comment.
note: I didn't realize that isempty counted blank strings, I thought it only matched empty (zero-length) strings.
Weird imo, not this PR's fault.
There was a problem hiding this comment.
I actually thought isempty only matched null and zero-length strings, not blank/whitespace. Isn't that what isblank is for? Or am I misunderstanding something?
| | True | Netagy | True | Netagy | | ||
| | True | Quility | True | Quility | | ||
| | True | | False | null | | ||
| +------------------+---------+----------------------+----------| |
There was a problem hiding this comment.
Fixed the table corner formatting, doctest passes locally now.
Adds `isnotempty(field)` function to PPL that returns true when a field is not null and not an empty string — the logical negation of `isempty(field)`. Implementation: NOT(IS_NULL(arg) OR IS_EMPTY(arg)) - ANTLR grammar: added ISNOTEMPTY token and parser rules in all three grammar modules (ppl, language-grammar, async-query-core) - BuiltinFunctionName: added IS_NOT_EMPTY enum constant - PPLFuncImpTable: registered Calcite implementation - Integration test: testIsNotEmpty in CalcitePPLConditionBuiltinFunctionIT - Documentation: added ISNOTEMPTY section to condition functions docs Resolves opensearch-project#5182 Signed-off-by: Luca Cavenaghi <lucacavenaghics97@gmail.com>
0ecc7f1 to
5eed3f2
Compare
|
Persistent review updated to latest commit 5eed3f2 |
|
@lucacavenaghi97 Sample dataset PUT notisempty_demo
{
"mappings": {
"properties": {
"id": {"type": "integer"},
"name": {"type": "keyword"}
}
}
}
POST notisempty_demo/_bulk?refresh=true
{"index":{}}
{"id":1,"name":"alice"}
{"index":{}}
{"id":2,"name":""}
{"index":{}}
{"id":3,"name":null}
{"index":{}}
{"id":4,"name":"bob"}
{"index":{}}
{"id":5}Query Result:
|

Description
Adds
isnotempty(field)to PPL. Returnstruewhen a field is not null and not empty string — logical negation ofisempty(field).Resolves #5182
Changes
ISNOTEMPTYtoken and parser rules in ppl, language-grammar, and async-query-core grammarsIS_NOT_EMPTYenum constant toBuiltinFunctionNameNOT(IS_NULL(arg) OR IS_EMPTY(arg))inPPLFuncImpTabletestIsNotEmptyintegration test