MCPcopy Create free account
hub / github.com/apache/paimon-rust / normalize_primary_keys

Method normalize_primary_keys

crates/paimon/src/spec/schema.rs:306–324  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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`.

Callers

nothing calls this directly

Calls 4

removeMethod · 0.80
trimMethod · 0.80
to_vecMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected