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

Function extract_options

crates/integrations/datafusion/src/sql_context.rs:1676–1702  ·  view source on GitHub ↗

Extract key-value pairs from [`CreateTableOptions`].

(opts: &CreateTableOptions)

Source from the content-addressed store, hash-verified

1674
1675/// Extract key-value pairs from [`CreateTableOptions`].
1676fn extract_options(opts: &CreateTableOptions) -> DFResult<Vec<(String, String)>> {
1677 let sql_options = match opts {
1678 CreateTableOptions::With(options)
1679 | CreateTableOptions::Options(options)
1680 | CreateTableOptions::TableProperties(options)
1681 | CreateTableOptions::Plain(options) => options,
1682 CreateTableOptions::None => return Ok(Vec::new()),
1683 };
1684 sql_options
1685 .iter()
1686 .map(|opt| match opt {
1687 SqlOption::KeyValue { key, value } => {
1688 let v = value.to_string();
1689 // Strip surrounding quotes from the value if present.
1690 let v = v
1691 .strip_prefix('\'')
1692 .and_then(|s| s.strip_suffix('\''))
1693 .unwrap_or(&v)
1694 .to_string();
1695 Ok((key.value.clone(), v))
1696 }
1697 other => Err(DataFusionError::Plan(format!(
1698 "Unsupported table option: {other}"
1699 ))),
1700 })
1701 .collect()
1702}
1703
1704fn is_table_not_exist(e: &paimon::Error) -> bool {
1705 matches!(e, paimon::Error::TableNotExist { .. })

Callers 3

handle_create_tableMethod · 0.85

Calls 2

PlanClass · 0.50
iterMethod · 0.45

Tested by 2