Extract key-value pairs from [`CreateTableOptions`].
(opts: &CreateTableOptions)
| 1674 | |
| 1675 | /// Extract key-value pairs from [`CreateTableOptions`]. |
| 1676 | fn 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 | |
| 1704 | fn is_table_not_exist(e: &paimon::Error) -> bool { |
| 1705 | matches!(e, paimon::Error::TableNotExist { .. }) |