[
https://issues.apache.org/jira/browse/NIFI-5678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16645433#comment-16645433
]
ASF GitHub Bot commented on NIFI-5678:
--------------------------------------
Github user ottobackwards commented on a diff in the pull request:
https://github.com/apache/nifi/pull/3060#discussion_r224205938
--- Diff:
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/schema/validation/StandardSchemaValidator.java
---
@@ -196,21 +196,32 @@ private boolean isTypeCorrect(final Object value,
final DataType dataType) {
return true;
case MAP:
- if (!(value instanceof Map)) {
- return false;
- }
-
- final MapDataType mapDataType = (MapDataType) dataType;
- final DataType valueDataType = mapDataType.getValueType();
- final Map<?, ?> map = (Map<?, ?>) value;
-
- for (final Object mapValue : map.values()) {
- if (!isTypeCorrect(mapValue, valueDataType)) {
- return false;
+ if (value instanceof Map) {
+ final MapDataType mapDataType = (MapDataType) dataType;
+ final DataType valueDataType =
mapDataType.getValueType();
+ final Map<?, ?> map = (Map<?, ?>) value;
+
+ for (final Object mapValue : map.values()) {
+ if (!isTypeCorrect(mapValue, valueDataType)) {
+ return false;
+ }
}
+ return true;
--- End diff --
Would this be the same if it was a MapRecord?
> ValidateRecord does not handle Map type correctly
> -------------------------------------------------
>
> Key: NIFI-5678
> URL: https://issues.apache.org/jira/browse/NIFI-5678
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Reporter: Matt Burgess
> Assignee: Matt Burgess
> Priority: Major
>
> Consider the following Avro Schema:
> {code}
> {
> "name" : "test",
> "type" : "record",
> "fields" : [ {
> "name" : "field1",
> "type" : {
> "type" : "map",
> "values" : "string"
> }
> } ]
> }
> {code}
> and corresponding JSON data adhering to the schema:
> {code}
> [{
> "field1": {
> "toto" : "v1",
> "titi" : "v2"
> }
> }]
> {code}
> ValidateRecord marks the record as invalid though it should be valid. The
> message in the provenance event is "Record #1 is invalid due to:
> MapRecord[{toto=v1, titi=v2}] is not a valid value for /field1: Value is of
> type org.apache.nifi.serialization.record.MapRecord but was expected to be of
> type MAP[STRING]".
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)