MCPcopy Create free account
hub / github.com/apache/datafusion / validate_unique_keys_generic

Function validate_unique_keys_generic

datafusion/functions-nested/src/map.rs:169–187  ·  view source on GitHub ↗
(array: &dyn Array)

Source from the content-addressed store, hash-verified

167}
168
169fn validate_unique_keys_generic(array: &dyn Array) -> Result<()> {
170 let mut seen_keys = HashSet::with_capacity(array.len());
171
172 for i in 0..array.len() {
173 let key = ScalarValue::try_from_array(array, i)?;
174
175 // Validation 1: Map keys cannot be null
176 if key.is_null() {
177 return exec_err!("map key cannot be null");
178 }
179
180 // Validation 2: Map keys must be unique
181 if seen_keys.contains(&key) {
182 return exec_err!("map key must be unique, duplicate key found: {}", key);
183 }
184 seen_keys.insert(key);
185 }
186 Ok(())
187}
188
189/// Validates that map keys are non-null and unique.
190fn validate_map_keys(array: &dyn Array) -> Result<()> {

Callers 1

validate_map_keysFunction · 0.85

Calls 4

lenMethod · 0.45
is_nullMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…