Freedom9339 commented on code in PR #8362:
URL: https://github.com/apache/nifi/pull/8362#discussion_r1889114835
##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java:
##########
@@ -231,7 +243,11 @@ protected Collection<ValidationResult>
customValidate(ValidationContext context)
}
// If no Expression Language is present, try parsing the schema
try {
- this.parseSchema(schema);
+ if (schema != null) {
+ this.parseSchema(schema);
+ } else if (!headerProp.asBoolean()) {
+ throw(new Exception("Schema cannot be empty if header is
false."));
Review Comment:
Done.
##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java:
##########
@@ -449,155 +465,147 @@ public void onTrigger(final ProcessContext context,
final ProcessSession session
final CsvPreference csvPref = getPreference(context, flowFile);
final boolean header = context.getProperty(HEADER).asBoolean();
final ComponentLog logger = getLogger();
- final String schema =
context.getProperty(SCHEMA).evaluateAttributeExpressions(flowFile).getValue();
- final CellProcessor[] cellProcs = this.parseSchema(schema);
- final boolean isWholeFFValidation =
context.getProperty(VALIDATION_STRATEGY).getValue().equals(VALIDATE_WHOLE_FLOWFILE.getValue());
+ String schema =
context.getProperty(SCHEMA).evaluateAttributeExpressions(flowFile).getValue();
+ CellProcessor[] cellProcs = null;
+ if (schema != null) {
+ cellProcs = this.parseSchema(schema);
+ }
+ final String validationStrategy =
context.getProperty(VALIDATION_STRATEGY).getValue();
+ final boolean isWholeFFValidation =
!validationStrategy.equals(VALIDATE_LINES_INDIVIDUALLY.getValue());
final boolean includeAllViolations =
context.getProperty(INCLUDE_ALL_VIOLATIONS).asBoolean();
- final AtomicReference<Boolean> valid = new AtomicReference<>(true);
- final AtomicReference<Boolean> isFirstLineValid = new
AtomicReference<>(true);
- final AtomicReference<Boolean> isFirstLineInvalid = new
AtomicReference<>(true);
- final AtomicReference<Integer> okCount = new AtomicReference<>(0);
- final AtomicReference<Integer> totalCount = new AtomicReference<>(0);
- final AtomicReference<FlowFile> invalidFF = new
AtomicReference<>(null);
- final AtomicReference<FlowFile> validFF = new AtomicReference<>(null);
- final AtomicReference<String> validationError = new
AtomicReference<>(null);
+ boolean valid = true;
+ int okCount = 0;
+ int totalCount = 0;
+ FlowFile invalidFF = null;
+ FlowFile validFF = null;
+ String validationError = null;
+ final AtomicReference<Boolean> isFirstLineValid = new
AtomicReference<Boolean>(true);
+ final AtomicReference<Boolean> isFirstLineInvalid = new
AtomicReference<Boolean>(true);
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]