corwinjoy commented on code in PR #16351: URL: https://github.com/apache/datafusion/pull/16351#discussion_r2136714217
########## 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: We could use some feedback on how to do the column keys. Originally, I had used a separator of '::' to match what is done with metadata fields. But TableParquetOptions redirects all '::' delimitors as seen here. https://github.com/corwinjoy/datafusion/blob/a81855fcbf3cfb63512c1ba124e1ebbfd5e6b15c/datafusion/common/src/config.rs#L2100 So, I'm not quite sure what to do here. For now, we use '.' to separate columns. -- 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