Skip to content

Commit 00c2191

Browse files
corwinjoyalamb
andauthored
fix: Add missing member to visitor for ConfigFileEncryptionProperties (#17103)
* Add missing member to visitor for ConfigFileEncryptionProperties Signed-off-by: Corwin Joy <[email protected]> * Remove extraneous comment Signed-off-by: Corwin Joy <[email protected]> * Fix TableParquetOptions reference after merging updated main branch Signed-off-by: Corwin Joy <[email protected]> --------- Signed-off-by: Corwin Joy <[email protected]> Co-authored-by: Andrew Lamb <[email protected]>
1 parent 0db14c8 commit 00c2191

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

datafusion/common/src/config.rs

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,43 @@ impl TableParquetOptions {
19181918
..self
19191919
}
19201920
}
1921+
1922+
/// Retrieves all configuration entries from this `TableParquetOptions`.
1923+
///
1924+
/// # Returns
1925+
///
1926+
/// A vector of `ConfigEntry` instances, representing all the configuration options within this
1927+
pub fn entries(self: &TableParquetOptions) -> Vec<ConfigEntry> {
1928+
struct Visitor(Vec<ConfigEntry>);
1929+
1930+
impl Visit for Visitor {
1931+
fn some<V: Display>(
1932+
&mut self,
1933+
key: &str,
1934+
value: V,
1935+
description: &'static str,
1936+
) {
1937+
self.0.push(ConfigEntry {
1938+
key: key[1..].to_string(),
1939+
value: Some(value.to_string()),
1940+
description,
1941+
})
1942+
}
1943+
1944+
fn none(&mut self, key: &str, description: &'static str) {
1945+
self.0.push(ConfigEntry {
1946+
key: key[1..].to_string(),
1947+
value: None,
1948+
description,
1949+
})
1950+
}
1951+
}
1952+
1953+
let mut v = Visitor(vec![]);
1954+
self.visit(&mut v, "", "");
1955+
1956+
v.0
1957+
}
19211958
}
19221959

19231960
impl ConfigField for TableParquetOptions {
@@ -2147,6 +2184,8 @@ impl ConfigField for ConfigFileEncryptionProperties {
21472184
let desc = "Metadata to use for the parquet footer";
21482185
self.footer_key_metadata_as_hex.visit(v, key.as_str(), desc);
21492186

2187+
self.column_encryption_properties.visit(v, key_prefix, desc);
2188+
21502189
let key = format!("{key_prefix}.aad_prefix_as_hex");
21512190
let desc = "AAD prefix to use";
21522191
self.aad_prefix_as_hex.visit(v, key.as_str(), desc);
@@ -2626,7 +2665,7 @@ impl Display for OutputFormat {
26262665
mod tests {
26272666
use crate::config::{
26282667
ConfigEntry, ConfigExtension, ConfigField, ConfigFileType, ExtensionOptions,
2629-
Extensions, TableOptions,
2668+
Extensions, TableOptions, TableParquetOptions,
26302669
};
26312670
use std::any::Any;
26322671
use std::collections::HashMap;
@@ -2884,7 +2923,7 @@ mod tests {
28842923
#[cfg(feature = "parquet_encryption")]
28852924
#[test]
28862925
fn parquet_encryption_factory_config() {
2887-
let mut parquet_options = crate::config::TableParquetOptions::default();
2926+
let mut parquet_options = TableParquetOptions::default();
28882927

28892928
assert_eq!(parquet_options.crypto.factory_id, None);
28902929
assert_eq!(parquet_options.crypto.factory_options.options.len(), 0);
@@ -2925,6 +2964,23 @@ mod tests {
29252964
.any(|item| item.key == "format.bloom_filter_enabled::col1"))
29262965
}
29272966

2967+
#[cfg(feature = "parquet")]
2968+
#[test]
2969+
fn parquet_table_parquet_options_config_entry() {
2970+
let mut table_parquet_options = TableParquetOptions::new();
2971+
table_parquet_options
2972+
.set(
2973+
"crypto.file_encryption.column_key_as_hex::double_field",
2974+
"31323334353637383930313233343530",
2975+
)
2976+
.unwrap();
2977+
let entries = table_parquet_options.entries();
2978+
assert!(entries
2979+
.iter()
2980+
.any(|item| item.key
2981+
== "crypto.file_encryption.column_key_as_hex::double_field"))
2982+
}
2983+
29282984
#[cfg(feature = "parquet")]
29292985
#[test]
29302986
fn parquet_table_options_config_metadata_entry() {

0 commit comments

Comments
 (0)