You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by mattyb149 <gi...@git.apache.org> on 2017/10/26 12:30:14 UTC

[GitHub] nifi pull request #2226: NIFI-4080: Added EL support to fields in ValidateCS...

GitHub user mattyb149 opened a pull request:

    https://github.com/apache/nifi/pull/2226

    NIFI-4080: Added EL support to fields in ValidateCSV

    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [x] Have you written or updated unit tests to verify your changes?
    - [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [x] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [x] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [x] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [x] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mattyb149/nifi NIFI-4080

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/2226.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2226
    
----
commit 6eb80347d833f573df8509e9eb969fc9cc5d64eb
Author: Matthew Burgess <ma...@apache.org>
Date:   2017-10-26T12:27:27Z

    NIFI-4080: Added EL support to fields in ValidateCSV

----


---

[GitHub] nifi pull request #2226: NIFI-4080: Added EL support to fields in ValidateCS...

Posted by patricker <gi...@git.apache.org>.
Github user patricker commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2226#discussion_r147551737
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java ---
    @@ -227,9 +231,9 @@ public void setPreference(final ProcessContext context) {
             // input is transferred over to Java as is. So when you type the characters "\"
             // and "n" into the UI the Java string will end up being those two characters
             // not the interpreted value "\n".
    -        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    -        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).getValue().charAt(0),
    -                context.getProperty(DELIMITER_CHARACTER).getValue().charAt(0), msgDemarcator).build());
    +        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).evaluateAttributeExpressions().getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    +        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0),
    +                context.getProperty(DELIMITER_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0), msgDemarcator).build());
    --- End diff --
    
    No concerns.


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    @mattyb149 there is a test failure because I just cherry-picked my changes on top of your PR, so when I run the tests, I didn't run the test you added here (sorry, my bad). This test is not valid anymore, since we cannot validate the schema since we have it only when we get the flow files. May you please remove `testValidateWithEL` then please? Thanks.


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    Are you comfortable giving a +1 without the other test failures? If so we can get a committer to merge. Thanks to both @mgaido91 and @patricker for improvements.


---

[GitHub] nifi pull request #2226: NIFI-4080: Added EL support to fields in ValidateCS...

Posted by patricker <gi...@git.apache.org>.
Github user patricker commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2226#discussion_r147335687
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java ---
    @@ -227,9 +231,9 @@ public void setPreference(final ProcessContext context) {
             // input is transferred over to Java as is. So when you type the characters "\"
             // and "n" into the UI the Java string will end up being those two characters
             // not the interpreted value "\n".
    -        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    -        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).getValue().charAt(0),
    -                context.getProperty(DELIMITER_CHARACTER).getValue().charAt(0), msgDemarcator).build());
    +        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).evaluateAttributeExpressions().getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    +        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0),
    +                context.getProperty(DELIMITER_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0), msgDemarcator).build());
    --- End diff --
    
    What do you think of waiting until `onTrigger` to build the CsvPreference so you can also evaluate the FlowFile's attributes when you call `evaluateAttributeExpressions`? Then each you can use broader scoped variables, or variables specified at the FlowFile leve.


---

[GitHub] nifi pull request #2226: NIFI-4080: Added EL support to fields in ValidateCS...

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2226#discussion_r147526473
  
    --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java ---
    @@ -227,9 +231,9 @@ public void setPreference(final ProcessContext context) {
             // input is transferred over to Java as is. So when you type the characters "\"
             // and "n" into the UI the Java string will end up being those two characters
             // not the interpreted value "\n".
    -        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    -        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).getValue().charAt(0),
    -                context.getProperty(DELIMITER_CHARACTER).getValue().charAt(0), msgDemarcator).build());
    +        final String msgDemarcator = context.getProperty(END_OF_LINE_CHARACTER).evaluateAttributeExpressions().getValue().replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");
    +        this.preference.set(new CsvPreference.Builder(context.getProperty(QUOTE_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0),
    +                context.getProperty(DELIMITER_CHARACTER).evaluateAttributeExpressions().getValue().charAt(0), msgDemarcator).build());
    --- End diff --
    
    That would be more useful, this was initially just a quick addition. There is something funky with unit tests when you call isExpressionLanguagePresent() from a custom validator, it throws an NPE. I will look into that and try to move it into onTrigger(). However if for some reason there is a property that must be evaluated early, or too much overhead in building the CsvPreference (not saying there is, just saying if there is), then I'd rather have all the properties either support flow file attributes or none, how does that sound?


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    thanks @mattyb149. The test failures are not related to this PR. They are caused by 3ca7c3e7a19c7f496a214d9b93ace43b1507c9ec. I am investigating them. I am not sure if it is possible to re-trigger a build for this PR, thanks.


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by pvillard31 <gi...@git.apache.org>.
Github user pvillard31 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    +1 as well, merging to master, thanks guys


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by mgaido91 <gi...@git.apache.org>.
Github user mgaido91 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    +1, locally it builds and passes all the tests


---

[GitHub] nifi pull request #2226: NIFI-4080: Added EL support to fields in ValidateCS...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi/pull/2226


---

[GitHub] nifi issue #2226: NIFI-4080: Added EL support to fields in ValidateCSV

Posted by mattyb149 <gi...@git.apache.org>.
Github user mattyb149 commented on the issue:

    https://github.com/apache/nifi/pull/2226
  
    We don't need to get rid of those tests; rather I think if no EL is present, then we should try parsing the schema for validity. It will be reparsed in onTrigger() anyway (whether it has EL or not).


---