(options: SVec<(SString, SString)>)
| 466 | } |
| 467 | |
| 468 | fn table_options_from_rhashmap(options: SVec<(SString, SString)>) -> TableOptions { |
| 469 | let mut options: HashMap<String, String> = options |
| 470 | .into_iter() |
| 471 | .map(|kv_pair| (kv_pair.0.to_string(), kv_pair.1.to_string())) |
| 472 | .collect(); |
| 473 | let current_format = options.remove("datafusion_ffi.table_current_format"); |
| 474 | |
| 475 | let mut table_options = TableOptions::default(); |
| 476 | let formats = [ |
| 477 | ConfigFileType::CSV, |
| 478 | ConfigFileType::JSON, |
| 479 | ConfigFileType::PARQUET, |
| 480 | ]; |
| 481 | for format in formats { |
| 482 | // It is imperative that if new enum variants are added below that they be |
| 483 | // included in the formats list above and in the extension check below. |
| 484 | let format_name = match &format { |
| 485 | ConfigFileType::CSV => "csv", |
| 486 | ConfigFileType::PARQUET => "parquet", |
| 487 | ConfigFileType::JSON => "json", |
| 488 | }; |
| 489 | let format_options: HashMap<String, String> = options |
| 490 | .iter() |
| 491 | .filter_map(|(k, v)| { |
| 492 | let (prefix, key) = k.split_once(".")?; |
| 493 | if prefix == format_name { |
| 494 | Some((format!("format.{key}"), v.to_owned())) |
| 495 | } else { |
| 496 | None |
| 497 | } |
| 498 | }) |
| 499 | .collect(); |
| 500 | if !format_options.is_empty() { |
| 501 | table_options.current_format = Some(format.clone()); |
| 502 | table_options |
| 503 | .alter_with_string_hash_map(&format_options) |
| 504 | .unwrap_or_else(|err| log::warn!("Error parsing table options: {err}")); |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | let extension_options: HashMap<String, String> = options |
| 509 | .iter() |
| 510 | .filter_map(|(k, v)| { |
| 511 | let (prefix, _) = k.split_once(".")?; |
| 512 | if !["json", "parquet", "csv"].contains(&prefix) { |
| 513 | Some((k.to_owned(), v.to_owned())) |
| 514 | } else { |
| 515 | None |
| 516 | } |
| 517 | }) |
| 518 | .collect(); |
| 519 | if !extension_options.is_empty() { |
| 520 | table_options |
| 521 | .alter_with_string_hash_map(&extension_options) |
| 522 | .unwrap_or_else(|err| log::warn!("Error parsing table options: {err}")); |
| 523 | } |
| 524 | |
| 525 | table_options.current_format = |
no test coverage detected
searching dependent graphs…