Normalize primary keys: optionally take from table options (`primary-key`), remove from options. Corresponds to Java `normalizePrimaryKeys`.
(
primary_keys: &[String],
options: &mut HashMap<String, String>,
)
| 304 | /// Normalize primary keys: optionally take from table options (`primary-key`), remove from options. |
| 305 | /// Corresponds to Java `normalizePrimaryKeys`. |
| 306 | fn normalize_primary_keys( |
| 307 | primary_keys: &[String], |
| 308 | options: &mut HashMap<String, String>, |
| 309 | ) -> crate::Result<Vec<String>> { |
| 310 | if let Some(pk) = options.remove(PRIMARY_KEY_OPTION) { |
| 311 | if !primary_keys.is_empty() { |
| 312 | return Err(crate::Error::ConfigInvalid { |
| 313 | message: "Cannot define primary key on DDL and table options at the same time." |
| 314 | .to_string(), |
| 315 | }); |
| 316 | } |
| 317 | return Ok(pk |
| 318 | .split(',') |
| 319 | .map(|s| s.trim().to_string()) |
| 320 | .filter(|s| !s.is_empty()) |
| 321 | .collect()); |
| 322 | } |
| 323 | Ok(primary_keys.to_vec()) |
| 324 | } |
| 325 | |
| 326 | /// Normalize partition keys: optionally take from table options (`partition`), remove from options. |
| 327 | /// Corresponds to Java `normalizePartitionKeys`. |