You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Paul Nahay <pn...@sprynet.com> on 2016/03/22 14:46:16 UTC

notEmpty

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#isempty

Why don't you have function "notEmpty"? This would be useful when combined with "allAttributes". 

I can't see any way, with your current set of functions, to determine that all of a set of attributes are not empty, using the "allAttributes" function. 

You have "isNull" and "notNull", why don't you have "notEmpty"?

Paul Nahay
pnahay@sprynet.com

Re: notEmpty

Posted by Andy LoPresto <al...@gmail.com>.
Paul,

Your comments regarding the accuracy of the expression language documentation were in a different message, so it’s entirely possible and likely that Matt has not seen them yet. In general, when a member of the team or community has responded to a message, the remainder of the community does not reply unless they have additional information or are interested in furthering the conversation. As your comments were addressed in the other thread, I would not expect Matt to respond to them here.

My understanding is that your request is for a single expression language method which evaluates *n* terms and will return true if all of the terms are populated (i.e. not null, not empty, and not whitespace characters only). Thus far, composability has been favored, as with limited developer resources, it is unlikely and inefficient for us to try and produce a single method for all possible combinations. Rather, we have focused on building the common component methods which users can combine to form their complex queries. At this point, I’m not inclined to see a significant advantage of “allAttributes(x, y, z):notEmpty()” over “allAttributes(x, y, z):isEmpty():not()” but if you feel differently, please explain why. Without looking into it further, I don’t believe it would be a significant development effort, but right now all the developers are pretty heavily-loaded with new feature work. Our roadmap is fairly accelerated with many highly-requested features.

Matt’s answer above does provide the result you are looking for as we understand it. I accept that the “English” reading of the expression language may indicate otherwise, but the empirical evidence from running the expression through the parser indicates it returns true if and only if all attributes specified have “non-empty” values as defined above. This is probably another opportunity for us to improve the documentation around these methods (changing the name of the methods or the order of operation of chained methods would break backward compatibility). I wrote a unit test case which specifically evaluates against the following three scenarios:

* all attributes are empty -> FALSE
* some attributes are empty, some are populated -> FALSE
* all attributes are populated -> TRUE

I have provided a very truncated version of TestQuery.java [1] with only the relevant unit test and helper method here [2]. The query you want can be expressed as:

Java String: `"${allAttributes(\"attr1\", \"attr2\", \"attr3\"):isEmpty():not()}"`

Typed into processor property: `${allAttributes("attr1", "attr2", "attr3"):isEmpty():not()}`

Note: Backticks (`) are for formatting and should not be included when typing the query.

If it helps for understanding, this is how I mentally parse the chain:

`allAttributes(“1”, “2”, “3”).isEmpty().not()` -> `“1”.isEmpty().not() && “2”.isEmpty().not() && “3”.isEmpty().not()`

One piece of advice: everyone on the lists is trying to help the community and offering the expertise they can, and often in their free/personal time. On mailing lists like this, typing long phrases in all caps comes across aggressively or as “yelling” and can dissuade people from spending their energy assisting with requests. Keeping the lists welcoming and encouraging for users of all skill levels is a goal of the community in order to encourage as much participation as possible.

Please let us know if you have any further issues or suggestions. Thanks.

[1] https://github.com/alopresto/nifi/blob/28c2a3e5a65e640935f0259bd162967ef3e0b396/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java
[2] https://gist.github.com/alopresto/faff5051f3c7b7102990

Andy LoPresto
alopresto.apache@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Mar 22, 2016, at 3:39 PM, Paul Nahay <pn...@sprynet.com> wrote:
> 
> Thanks for responding, however...
> 
> 
> 
> Your expression below evaluates to true if IT IS NOT THE CASE THAT ALL THREE ATTRIBUTES ARE EMPTY.
> 
> 
> 
> But I need an expression that evalutes to true if IT IS THE CASE THAT ALL THREE ATTRIBUTES ARE NOT EMPTY.
> 
> 
> 
> There are two entirely different things.
> 
> 
> 
> Thus, if attr1 is set (thus is “not empty”), but the others are not (thus they “are empty”), your expression evaluates to true.
> 
> 
> 
> But I need to ensure that NONE of the three “are empty”. I want an expression that in the case given above evaluates to false.
> 
> 
> 
> Actually, I know how to make an expression that does what I need, however, it is more confusing than it needs to be. The simpler expression that one would desire to write REQUIRES that you offered a “notEmpty” function, thus would be expressible as:
> 
> 
> 
> ${allAttributes('attr1','attr2','attr3'):notEmpty()}
> 
> 
> 
> Again, this gives true only if all three attributes are not empty. The expression you suggest gives true if even only ONE of the attributes is not empty!
> 
> 
> 
> The lack of “notEmpty()” seems a very grave omission on your part.
> 
> 
> 
> And, you have no comment about the errors in your documentation for “isEmpty” and “allAttributes” that I told you?
> 
> 
> 
> --Paul Nahay
> 
> 
> 
> 
> 
> 
> 
> From: Matthew Clarke [mailto:matt.clarke.138@gmail.com]
> Sent: Tuesday, March 22, 2016 11:07 AM
> To: dev@nifi.apache.org; Paul Nahay
> Subject: Re: notEmpty
> 
> 
> 
> Paul,
> 
>    You can achieve what you are trying to do by using the not function.
> 
> 
> 
> let assume the attributes you want to check to make sure they have a vlaue set are attr1, attr2, and attr3.
> 
> The expression would be ${allAttributes('attr1','attr2','attr3'):isEmpty():not()}
> 
> Thanks,
> 
> Matt
> 
> 
> 
> On Tue, Mar 22, 2016 at 9:46 AM, Paul Nahay <pn...@sprynet.com> wrote:
> 
> https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#isempty
> 
> Why don't you have function "notEmpty"? This would be useful when combined with "allAttributes".
> 
> I can't see any way, with your current set of functions, to determine that all of a set of attributes are not empty, using the "allAttributes" function.
> 
> You have "isNull" and "notNull", why don't you have "notEmpty"?
> 
> Paul Nahay
> pnahay@sprynet.com
> 
> 
> 


RE: notEmpty

Posted by Paul Nahay <pn...@sprynet.com>.
Thanks for responding, however...

 

Your expression below evaluates to true if IT IS NOT THE CASE THAT ALL THREE ATTRIBUTES ARE EMPTY.

 

But I need an expression that evalutes to true if IT IS THE CASE THAT ALL THREE ATTRIBUTES ARE NOT EMPTY.

 

There are two entirely different things.

 

Thus, if attr1 is set (thus is “not empty”), but the others are not (thus they “are empty”), your expression evaluates to true.

 

But I need to ensure that NONE of the three “are empty”. I want an expression that in the case given above evaluates to false.

 

Actually, I know how to make an expression that does what I need, however, it is more confusing than it needs to be. The simpler expression that one would desire to write REQUIRES that you offered a “notEmpty” function, thus would be expressible as:

 

${allAttributes('attr1','attr2','attr3'):notEmpty()}

 

Again, this gives true only if all three attributes are not empty. The expression you suggest gives true if even only ONE of the attributes is not empty!

 

The lack of “notEmpty()” seems a very grave omission on your part. 

 

And, you have no comment about the errors in your documentation for “isEmpty” and “allAttributes” that I told you?

 

--Paul Nahay

 

 

 

From: Matthew Clarke [mailto:matt.clarke.138@gmail.com] 
Sent: Tuesday, March 22, 2016 11:07 AM
To: dev@nifi.apache.org; Paul Nahay
Subject: Re: notEmpty

 

Paul,

    You can achieve what you are trying to do by using the not function.

 

let assume the attributes you want to check to make sure they have a vlaue set are attr1, attr2, and attr3.

The expression would be ${allAttributes('attr1','attr2','attr3'):isEmpty():not()}

Thanks,

Matt

 

On Tue, Mar 22, 2016 at 9:46 AM, Paul Nahay <pn...@sprynet.com> wrote:

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#isempty

Why don't you have function "notEmpty"? This would be useful when combined with "allAttributes".

I can't see any way, with your current set of functions, to determine that all of a set of attributes are not empty, using the "allAttributes" function.

You have "isNull" and "notNull", why don't you have "notEmpty"?

Paul Nahay
pnahay@sprynet.com

 


Re: notEmpty

Posted by Matthew Clarke <ma...@gmail.com>.
Paul,
    You can achieve what you are trying to do by using the not function.

let assume the attributes you want to check to make sure they have a vlaue
set are attr1, attr2, and attr3.

The expression would be
*${allAttributes('attr1','attr2','attr3'):isEmpty():not()}*

Thanks,
Matt

On Tue, Mar 22, 2016 at 9:46 AM, Paul Nahay <pn...@sprynet.com> wrote:

>
> https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#isempty
>
> Why don't you have function "notEmpty"? This would be useful when combined
> with "allAttributes".
>
> I can't see any way, with your current set of functions, to determine that
> all of a set of attributes are not empty, using the "allAttributes"
> function.
>
> You have "isNull" and "notNull", why don't you have "notEmpty"?
>
> Paul Nahay
> pnahay@sprynet.com
>