[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/2207 ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user frett27 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145189535 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- and if you also tests it , it's OK ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user frett27 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145189423 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- OK let's change that to MapRecord, i'm sure it's reliable, because we use it on dev plateform, for the "instanceof Map" you suggest i'm not sure of the impact. ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145185287 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- I can post my flow and sample Avro file if you'd like to see what I mean ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145185126 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- I have the following schema in my test flow: `{ "type": "record", "name": "A","fields": [ {"name": "a", "type": "string"}, {"name": "c", "type": [ "null", {"type" : "map","values" : "string"} ] } ] }` When I debug through the processor to AvroTypeUtil, I get a MapRecord as the type of "value", not Map. If it could be either, we could just check for either? ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user frett27 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145175950 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/avro/AvroTypeUtil.java --- @@ -691,6 +697,10 @@ private static boolean isCompatibleDataType(final Object value, final DataType d return true; } break; +case MAP: +if (value instanceof Map) { --- End diff -- in debugging initially, the given value was MapRecord, ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user frett27 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145175558 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- my uderstanding was that the map presence cause the issue in union type, whether or not, the map is filled, (instance of map will be returned) ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user frett27 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145175249 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/avro/AvroTypeUtil.java --- @@ -691,6 +697,10 @@ private static boolean isCompatibleDataType(final Object value, final DataType d return true; } break; +case MAP: +if (value instanceof Map) { --- End diff -- The MapRecord was my initial post, you suggested to open to Map , type. the probleme was when the map is present in the union ("null", "record"). ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145169320 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- Also it could check the records to make sure the field values are what you expect (null vs not-null, e.g.) ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145169617 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/avro/AvroTypeUtil.java --- @@ -691,6 +697,10 @@ private static boolean isCompatibleDataType(final Object value, final DataType d return true; } break; +case MAP: +if (value instanceof Map) { --- End diff -- What kind of flow (which processors, e.g.) did you use to test this with? When I use ConvertRecord, value is a MapRecord not a Map, which causes this not to work. Perhaps we should check for both here? ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2207#discussion_r145169184 --- Diff: nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/test/java/org/apache/nifi/avro/TestAvroTypeUtil.java --- @@ -239,4 +243,20 @@ public void testComplicatedRecursiveSchema() { Assert.assertEquals(recordASchema, ((RecordDataType)recordBParentField.get().getDataType()).getChildSchema()); } +@Test +public void testMapWithNullSchema() throws IOException { + +Schema recursiveSchema = new Schema.Parser().parse(getClass().getResourceAsStream("schema.json")); + +// Make sure the following doesn't throw an exception +RecordSchema recordASchema = AvroTypeUtil.createSchema(recursiveSchema.getTypes().get(0)); + +// check the fix with the proper file +try(DataFileStream r = new DataFileStream<>(getClass().getResourceAsStream("data.avro"), --- End diff -- Can you explain more about what's going on here, including what is in the data.avro file? When I run avro-tools tojson on it, I get the following: ``` java -jar avro-tools-1.8.1.jar tojson datasets/data.avro {"a.A":{"o":{"a.O":{"hash":{"map":{}} ``` Perhaps it would be good to have a test file that has a record with a non-null value for hash, as well as a record with a null value for hash? ---
[GitHub] nifi pull request #2207: NIFI-4441 patch avro maps in union types
GitHub user frett27 opened a pull request: https://github.com/apache/nifi/pull/2207 NIFI-4441 patch avro maps in union types 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- where 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)? - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? - [ ] 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/frett27/nifi nifi-4441 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/2207.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 #2207 commit 30b3596ac351405ea33d09b9737cece257d8ff54 Author: Patrice FreydiereDate: 2017-10-11T20:17:15Z patch avro maps in union types ---