kevinjqliu commented on code in PR #4309:
URL: https://github.com/apache/iceberg-python/pull/4309#discussion_r4515886881
##########
pyiceberg/io/pyarrow.py:
##########
@@ -1158,11 +1159,34 @@ def _get_file_format(file_format: FileFormat, **kwargs:
dict[str, Any]) -> ds.Fi
raise ValueError(f"Unsupported file format: {file_format}")
+def _get_data_file_format(data_file: DataFile, **kwargs: Any) -> ds.FileFormat:
+ if data_file.key_metadata is None:
+ return _get_file_format(data_file.file_format, **kwargs)
+ if data_file.file_format != FileFormat.PARQUET:
+ raise ValueError(f"Cannot read encrypted {data_file.file_format} file
{data_file.file_path}: only Parquet is supported")
+ return
ds.ParquetFileFormat(decryption_properties=_parquet_decryption_properties(data_file.key_metadata),
**kwargs)
+
+
+def _parquet_decryption_properties(key_metadata: bytes) ->
pq.FileDecryptionProperties:
+ from packaging import version
+ from pyarrow.parquet import encryption
+
+ MIN_PYARROW_VERSION_SUPPORTING_PARQUET_DECRYPTION = "25.0.0"
+ if version.parse(pyarrow.__version__) <
version.parse(MIN_PYARROW_VERSION_SUPPORTING_PARQUET_DECRYPTION):
Review Comment:
yea i think we do this pattern in a few places already.
its not pretty but its what we got 🤷
--
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]