(array: &dyn Array)
| 167 | } |
| 168 | |
| 169 | fn 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. |
| 190 | fn validate_map_keys(array: &dyn Array) -> Result<()> { |
no test coverage detected
searching dependent graphs…