zhongyujiang commented on code in PR #2639:
URL: https://github.com/apache/iceberg/pull/2639#discussion_r935414614
##########
parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java:
##########
@@ -225,6 +243,36 @@ private WriteBuilder
createContextFunc(Function<Map<String, String>, Context> ne
return this;
}
+ private FileEncryptionProperties
createEncryptionProperties(NativeFileCryptoParameters nativeParameters) {
+ Preconditions.checkArgument(nativeParameters != null, "Null native
crypto parameters");
+
+ ParquetCipher parquetEncryptionAlgorithm;
+ if (nativeParameters.encryptionAlgorithm() == null) {
+ parquetEncryptionAlgorithm = ParquetCipher.AES_GCM_V1; // default
+ LOG.info("No encryption algorithm specified. Using Parquet default -
AES_GCM_V1");
+ } else {
+ EncryptionAlgorithm icebergEncryptionAlgorithm =
nativeParameters.encryptionAlgorithm();
Review Comment:
Nit: a switch would look simpler than an if block.
##########
parquet/src/main/java/org/apache/iceberg/parquet/Parquet.java:
##########
@@ -225,6 +243,36 @@ private WriteBuilder
createContextFunc(Function<Map<String, String>, Context> ne
return this;
}
+ private FileEncryptionProperties
createEncryptionProperties(NativeFileCryptoParameters nativeParameters) {
+ Preconditions.checkArgument(nativeParameters != null, "Null native
crypto parameters");
+
+ ParquetCipher parquetEncryptionAlgorithm;
+ if (nativeParameters.encryptionAlgorithm() == null) {
+ parquetEncryptionAlgorithm = ParquetCipher.AES_GCM_V1; // default
+ LOG.info("No encryption algorithm specified. Using Parquet default -
AES_GCM_V1");
+ } else {
+ EncryptionAlgorithm icebergEncryptionAlgorithm =
nativeParameters.encryptionAlgorithm();
+ if (icebergEncryptionAlgorithm.equals(EncryptionAlgorithm.AES_GCM)) {
+ parquetEncryptionAlgorithm = ParquetCipher.AES_GCM_V1;
+ } else if
(icebergEncryptionAlgorithm.equals(EncryptionAlgorithm.AES_GCM_CTR)) {
+ parquetEncryptionAlgorithm = ParquetCipher.AES_GCM_CTR_V1;
+ } else {
+ throw new ParquetCryptoRuntimeException("Can't create parquet
encryption properties - " +
+ "unsupported algorithm: " +
nativeParameters.encryptionAlgorithm());
+ }
+ }
+
+ ByteBuffer footerDataKey = nativeParameters.fileKey();
+ if (null == footerDataKey) {
Review Comment:
File key must not be null when we push down encryption, right? If so, can we
move this check to NativeFileCryptoParameters#build ? So we won't need to check
if the file key is null every time when converting NativeFileCryptoParameters
to Parquet / ORC config.
--
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]