You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by GitBox <gi...@apache.org> on 2020/07/22 20:00:01 UTC

[GitHub] [parquet-mr] Fokko opened a new pull request #804: PARQUET-1887: Allow writing after an exception

Fokko opened a new pull request #804:
URL: https://github.com/apache/parquet-mr/pull/804


   After having an exception when writing, the subsequent writes would also
   fail. This was because the group wasn't closed properly.
   
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [ ] My PR addresses the following [Parquet Jira](https://issues.apache.org/jira/browse/PARQUET/) issues and references them in the PR title. For example, "PARQUET-1234: My Parquet PR"
     - https://issues.apache.org/jira/browse/PARQUET-1887
     - In case you are adding a dependency, check if the license complies with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   
   ### Tests
   
   - [ ] My PR adds the following unit tests __OR__ does not need testing for this extremely good reason:
   
   ### Commits
   
   - [ ] My commits all reference Jira issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [ ] In case of new functionality, my PR adds documentation that describes how to use it.
     - All the public functions and the classes in the PR contain Javadoc that explain what it does
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [parquet-mr] gszadovszky commented on a change in pull request #804: PARQUET-1887: Allow writing after an exception

Posted by GitBox <gi...@apache.org>.
gszadovszky commented on a change in pull request #804:
URL: https://github.com/apache/parquet-mr/pull/804#discussion_r460821213



##########
File path: parquet-avro/src/test/java/org/apache/parquet/avro/TestArrayCompatibility.java
##########
@@ -56,6 +59,30 @@ public static void setupNewBehaviorConfiguration() {
         AvroSchemaConverter.ADD_LIST_ELEMENT_RECORDS, false);
   }
 
+  @Test
+  public void testReadEmptyParquetFileWriteNull() throws IOException {
+    final Schema schema;
+    try (InputStream avroSchema = Resources.getResource("persons.json").openStream()) {
+      schema = new Schema.Parser().parse(avroSchema);
+    }
+
+    try (ParquetWriter<GenericRecord> writer =
+           AvroParquetWriter.<GenericRecord>builder(new org.apache.hadoop.fs.Path("/tmp/persons.parquet"))
+             .withSchema(schema)
+             .build()) {
+
+      // To trigger exception, add array with null element.
+      try {
+        writer.write(new GenericRecordBuilder(schema).set("address", Arrays.asList("first", null, "last")).build());
+      } catch (NullPointerException e) {

Review comment:
       I would add a `fail` in the `try` block after write so we fail if no exception occurred.

##########
File path: parquet-avro/src/test/java/org/apache/parquet/avro/TestArrayCompatibility.java
##########
@@ -56,6 +59,30 @@ public static void setupNewBehaviorConfiguration() {
         AvroSchemaConverter.ADD_LIST_ELEMENT_RECORDS, false);
   }
 
+  @Test
+  public void testReadEmptyParquetFileWriteNull() throws IOException {
+    final Schema schema;
+    try (InputStream avroSchema = Resources.getResource("persons.json").openStream()) {
+      schema = new Schema.Parser().parse(avroSchema);
+    }
+
+    try (ParquetWriter<GenericRecord> writer =
+           AvroParquetWriter.<GenericRecord>builder(new org.apache.hadoop.fs.Path("/tmp/persons.parquet"))
+             .withSchema(schema)
+             .build()) {
+
+      // To trigger exception, add array with null element.
+      try {
+        writer.write(new GenericRecordBuilder(schema).set("address", Arrays.asList("first", null, "last")).build());
+      } catch (NullPointerException e) {
+        // We expect this one to fail
+      }
+
+      // At this point all future calls to writer.write will fail

Review comment:
       Not sure about this comment. I've thought that's the point of this fix to not to fail after the previous exception.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org