Skip to content

NIFI-4242 Allow quote and escape chars for CSV to be 'undefined'.#2088

Closed
Wesley-Lawrence wants to merge 2 commits intoapache:masterfrom
Wesley-Lawrence:NIFI-4242
Closed

NIFI-4242 Allow quote and escape chars for CSV to be 'undefined'.#2088
Wesley-Lawrence wants to merge 2 commits intoapache:masterfrom
Wesley-Lawrence:NIFI-4242

Conversation

@Wesley-Lawrence
Copy link
Contributor

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:

  • [✓] Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • [✓] 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.

  • [✓] Has your PR been rebased against the latest commit within the target branch (typically master)?

  • [✓] Is your initial contribution a single, squashed commit?

For code changes:

  • [✓] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • [✓] Have you written or updated unit tests to verify your changes?
  • [N/A] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • [N/A] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • [N/A] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • [N/A] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • [N/A] 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.


@Override
public PropertyValue getProperty(final PropertyDescriptor property) {
String value = properties.get(property);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Wesley-Lawrence I don't think this is really what we want here. The concept of a default value is 'use this if the value is null'. So changing this would be inconsistent with how the StandardProcessContext works as well. I think the more desirable approach would be to just update the SingleCharacterValidator being used such that we allow 0 or 1 character. Then, this would allow an empty string to be used as the delimiter, which I believe is equivalent.

@Wesley-Lawrence
Copy link
Contributor Author

@markap14 Thanks for the feedback, and my apologies for the delayed response. Hopefully this latest commit address your feedback.

Thanks so much for taking the time to review these PRs 🙂

public ValidationResult validate(final String subject, final String input, final ValidationContext context) {
final String unescaped = CSVUtils.unescape(input);
if (unescaped.length() != 1) {
if (allowEmpty && unescaped.length() > 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't seem to be exactly right. If allowEmpty == true and unescaped.length() is 0, then this 'if clause' evaluates to false. So we will go to the next line, and unescaped.length() == 0 so it's invalid. As a result, when I tried to set Quote Character to empty string, the processor is invalid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll have to figure out why the unit tests didn't catch that...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. The unit tests don't trigger SingleCharValidator.

@markap14
Copy link
Contributor

markap14 commented Sep 11, 2017

@Wesley-Lawrence no problem. I think the logic is a bit off on the latest commit, though. Commented inline.

@Wesley-Lawrence
Copy link
Contributor Author

@markap14 Alright, should be all fixed up now. I made sure to test out a live Flow this time, and make sure the functionality worked outside of just unit tests.

@joewitt
Copy link
Contributor

joewitt commented Oct 6, 2017

@Wesley-Lawrence can you please rebase to resolve the conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants