adamreeve commented on code in PR #16351:
URL: https://github.com/apache/datafusion/pull/16351#discussion_r2136733767


##########
datafusion/common/src/config.rs:
##########
@@ -188,6 +195,338 @@ macro_rules! config_namespace {
     }
 }
 
+#[derive(Clone, Default, Debug, PartialEq)]
+pub struct ConfigFileEncryptionProperties {
+    pub encrypt_footer: bool, // default = false
+    pub footer_key_as_hex: String,
+    pub footer_key_metadata_as_hex: String,
+    pub column_keys_as_hex: HashMap<String, String>,
+    pub column_metadata_as_hex: HashMap<String, String>,
+    pub aad_prefix_as_hex: String,
+    pub store_aad_prefix: bool, //  default = false
+}
+
+impl ConfigFileEncryptionProperties {
+    /// Return new default TableParquetOptions
+    pub fn new() -> Self {
+        Self::default()
+    }
+}
+
+impl ConfigField for ConfigFileEncryptionProperties {
+    fn visit<V: Visit>(&self, v: &mut V, key_prefix: &str, _description: 
&'static str) {
+        let key = format!("{key_prefix}.encrypt_footer");
+        let desc = "Encrypt the footer";
+        self.encrypt_footer.visit(v, key.as_str(), desc);
+
+        let key = format!("{key_prefix}.footer_key_as_hex");
+        let desc = "Key to use for the parquet footer";
+        self.footer_key_as_hex.visit(v, key.as_str(), desc);
+
+        let key = format!("{key_prefix}.footer_key_metadata_as_hex");
+        let desc = "Metadata to use for the parquet footer";
+        self.footer_key_metadata_as_hex.visit(v, key.as_str(), desc);
+
+        let desc = "Per column encryption keys";
+        for (col_name, col_val) in self.column_keys_as_hex.iter() {
+            let key = format!("{key_prefix}.column_keys_as_hex.{col_name}");
+            col_val.visit(v, key.as_str(), desc);
+        }
+
+        let desc = "Per column metadata";
+        for (col_name, col_val) in self.column_metadata_as_hex.iter() {
+            let key = 
format!("{key_prefix}.column_metadata_as_hex.{col_name}");
+            col_val.visit(v, key.as_str(), desc);
+        }
+
+        let key = format!("{key_prefix}.aad_prefix_as_hex");
+        let desc = "AAD prefix to use";
+        self.aad_prefix_as_hex.visit(v, key.as_str(), desc);
+
+        let key = format!("{key_prefix}.store_aad_prefix");
+        let desc = "If true, store the AAD prefix";
+        self.store_aad_prefix.visit(v, key.as_str(), desc);
+    }
+
+    fn set(&mut self, key: &str, value: &str) -> Result<()> {
+        // Any hex encoded values must be pre-encoded using
+        // hex::encode() before calling set.
+        if key.starts_with("column_keys_as_hex.") {
+            let k = match key.split(".").collect::<Vec<_>>()[..] {

Review Comment:
   If the encryption related settings were directly set on the 
`TableParquetOptions` or a `crypto`/`encryption` namespace rather than in 
`ParquetOptions` then I think we could avoid this issue. But then they'd 
probably need to be included in `ParquetReadOptions` too to work with 
`SessionContext::read_parquet` (see related comment at 
https://github.com/apache/datafusion/pull/16351/files#r2136718671).



-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to