[ 
https://issues.apache.org/jira/browse/NIFI-4893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16370269#comment-16370269
 ] 

ASF GitHub Bot commented on NIFI-4893:
--------------------------------------

Github user gardellajuanpablo commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2480#discussion_r169389143
  
    --- Diff: 
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/RecordField.java
 ---
    @@ -76,8 +77,12 @@ public RecordField(final String fieldName, final 
DataType dataType, final Object
             } else {
                 this.aliases = Collections.unmodifiableSet(aliases);
             }
    -
    -        this.defaultValue = defaultValue;
    +        if (RecordFieldType.ARRAY.equals(dataType.getFieldType()) && 
(defaultValue instanceof String
    +                || defaultValue instanceof Number || defaultValue 
instanceof Boolean)) {
    --- End diff --
    
    Yes, it solves the reported issue, but it makes the test fails. It is 
required to think another solution approach. It is not as simple I initially 
thought


> Cannot convert Avro schemas to Record schemas with default value in arrays
> --------------------------------------------------------------------------
>
>                 Key: NIFI-4893
>                 URL: https://issues.apache.org/jira/browse/NIFI-4893
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.5.0, 1.6.0
>         Environment: ALL
>            Reporter: Gardella Juan Pablo
>            Priority: Major
>         Attachments: issue1.zip
>
>
> Given an Avro Schema that has a default array defined, it is not possible to 
> be converted to a Nifi Record Schema.
> To reproduce the bug, try to convert the following Avro schema to Record 
> Schema:
> {code}
> {
>     "type": "record",
>     "name": "Foo1",
>     "namespace": "foo.namespace",
>     "fields": [
>         {
>             "name": "listOfInt",
>             "type": {
>                 "type": "array",
>                 "items": "int"
>             },
>             "doc": "array of ints",
>             "default": 0
>         }
>     ]
> }
> {code}
>  
> Using org.apache.nifi.avro.AvroTypeUtil class. Attached a maven project to 
> reproduce the issue and also the fix.
> * To reproduce the bug, run "mvn clean test"
> * To test the fix, run "mvn clean test -Ppatch".
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to