nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff <jtsw...@gmail.com>
Subject Re: Can't Chain "count()" with "plus()"
Date Tue, 23 Aug 2016 19:43:53 GMT
I don't think it's necessary to document all those cases, personally.  The
purpose of the function is to split the value given to the function by the
delineating character given, and it simply does that.  You can add trim,
length, and gt functions to the chain if you want to "clean up" the input
as follows:

${allDelineatedValues("aaa ,bbb, ccc, ", ","):trim():length():gt(0):count()}

This will split the given string on the comma character, and end up with 4
tokens.  Chaining the trim, length, and gt functions on each token, and
then aggregating with count, a result of 3 will be provided.

If you would like to propose changes to the documentation, please create a
JIRA on the Apache NiFi JIRA [1].

[1] https://issues.apache.org/jira/browse/NIFI

On Tue, Aug 23, 2016 at 3:19 PM Paul Nahay <pnahay@sprynet.com> wrote:

> >allDelineatedValues
>
>
> Also, your documentation doesn't make clear what happens when there is
> whitespace between the delimiters, to the left of the first delimiter
> found, or to the right of the last delimiter found. I haven't tested
> thoroughly, but it seems to me that it doesn't "find" an "empty string"
> that sits just past the right-most delimiter.
>
>
> In any event, I feel you should make clearer in the documentation exactly
> how this function behaves when any whitespace or NO values are found
> between or on the outside of the delimiters.
>
> -----Original Message-----
> From: Jeff
> Sent: Aug 23, 2016 3:00 PM
> To: Paul Nahay , "dev@nifi.apache.org"
> Subject: Re: Can't Chain "count()" with "plus()"
>
> Paul,
>
> Also, the table of examples shows the results of the example expressions
> that use the allDelinatedValues function in conjunction with function
> chaining, not the result of the allDelineatedValues function itself, in
> which case the types and values shown for each example are correct.
>
> On Tue, Aug 23, 2016 at 2:53 PM Jeff <jtswork@gmail.com> wrote:
>
>> Paul,
>>
>> I refer you to the documentation for count[1], which states: "Aggregate
>> function that counts the number of non-null, non-false values returned"
>>
>> [1]
>> https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#count
>>
>> On Tue, Aug 23, 2016 at 2:37 PM Paul Nahay <pnahay@sprynet.com> wrote:
>>
>>> Thanks.
>>>
>>> However, your documentation is lacking, because in your documentation
>>> for "allDelineatedValues", there is nothing that explains how ":count()"
>>> can be applied to:
>>> *Return Type*: Boolean
>>> meaning, how ":count()" can be applied to each boolean separately to
>>> produce a "4".
>>>
>>> Yes, I understand what it's doing, but your documentation doesn't
>>> explain what it needs to. If this is true:
>>>
>>> *Return Type*: Boolean
>>>
>>> then your table with examples with "Value" in the right-hand column
>>> should have only booleans, not the integer 4 in it.
>>>
>>> Paul
>>>
>>> -----Original Message-----
>>> From: Jeff
>>> Sent: Aug 23, 2016 1:00 PM
>>> To: Paul Nahay , "dev@nifi.apache.org"
>>> Subject: Re: Can't Chain "count()" with "plus()"
>>>
>>> Hello Paul,
>>>
>>> The documentation for allDelineatedValues[1] states that each of the
>>> resulting values are evaluated against the rest of the Expression.  You
>>> need to use an embedded expression, since you don't want the plus function
>>> to be evaluated against each split from allDelineatedValues.  Try this
>>> slightly more complex expression:
>>>
>>> ${literal(${allDelineatedValues("aaa,bbb,ccc",","):count()}):plus(1)}
>>>
>>> [1]
>>> https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#alldelineatedvalues
>>>
>>> On Tue, Aug 23, 2016 at 12:21 PM Paul Nahay <pnahay@sprynet.com> wrote:
>>>
>>>> The following NiFi Expression Language construct gives me an error, and
>>>> I don't understand why:
>>>>
>>>> ${allDelineatedValues("aaa,bbb,ccc",","):count():plus(1)}
>>>>
>>>> It's fine without the ":plus(1)", but fails with it, with this error:
>>>>
>>>> AttributeExpressionLanguageException:
>>>> Cannot evaluate Expression because it attempts to reference multiple
>>>> attributes but does not use a reducing function
>>>>
>>>> (I am typing the error message above)
>>>>
>>>> It would seem like I should be able to add 1 to a count.
>>>>
>>>> It's NiFi version 0.6.1.c
>>>>
>>>>
>>>> Paul Nahay
>>>> 1013 Rosemere Ave.
>>>> Silver Spring, MD 20904-3008
>>>> 301-680-3825 (home)
>>>> 301-806-9265 (cell)
>>>> pnahay@sprynet.com
>>>>
>>>
>>> Paul Nahay
>>> 1013 Rosemere Ave.
>>> Silver Spring, MD 20904-3008
>>> 301-680-3825 (home)
>>> 301-806-9265 (cell)pnahay@sprynet.com
>>>
>>>
>>>
>>>
> Paul Nahay
> 1013 Rosemere Ave.
> Silver Spring, MD 20904-3008
> 301-680-3825 (home)
> 301-806-9265 (cell)pnahay@sprynet.com
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message