anxkhn commented on code in PR #3663:
URL: https://github.com/apache/parquet-java/pull/3663#discussion_r3593754023


##########
parquet-hadoop/src/test/java/org/apache/parquet/hadoop/TestParquetFileWriter.java:
##########
@@ -1498,6 +1505,94 @@ public void 
testMergeMetadataWithNoConflictingKeyValues() {
     assertEquals("d", mergedValues.get("c"));
   }
 
+  @Test
+  public void testConstructorClosesStreamWhenEncryptedColumnMissing() throws 
Exception {
+    ColumnEncryptionProperties missingColumn = 
ColumnEncryptionProperties.builder("not_in_schema")
+        .withKey("0123456789012345".getBytes(StandardCharsets.UTF_8))
+        .build();
+    Map<ColumnPath, ColumnEncryptionProperties> encryptedColumns = new 
HashMap<>();
+    encryptedColumns.put(missingColumn.getPath(), missingColumn);
+    FileEncryptionProperties encryptionProperties = 
FileEncryptionProperties.builder(
+            "0123456789012345".getBytes(StandardCharsets.UTF_8))
+        .withEncryptedColumns(encryptedColumns)
+        .build();
+
+    RecordingOutputFile file = new RecordingOutputFile();
+    try {
+      new ParquetFileWriter(
+          file,
+          SCHEMA,
+          CREATE,
+          DEFAULT_BLOCK_SIZE,
+          MAX_PADDING_SIZE_DEFAULT,
+          ParquetProperties.DEFAULT_COLUMN_INDEX_TRUNCATE_LENGTH,
+          ParquetProperties.DEFAULT_STATISTICS_TRUNCATE_LENGTH,
+          ParquetProperties.DEFAULT_PAGE_WRITE_CHECKSUM_ENABLED,
+          encryptionProperties);
+      fail("Expected ParquetCryptoRuntimeException for an encrypted column 
absent from the schema");

Review Comment:
   Updated the exception assertion to AssertJ and included the expected 
message. Thanks.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to