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

Function load

crates/integrations/datafusion/src/system_tables/mod.rs:130–155  ·  view source on GitHub ↗

Loads ` $ ` from the catalog and wraps it as a system table provider. - Unknown `system_name` → `Ok(None)` (DataFusion reports "table not found") - Base table missing → `Err(Plan)` so users can distinguish it from an unknown system name

(
    catalog: Arc<dyn Catalog>,
    database: String,
    base: String,
    system_name: String,
)

Source from the content-addressed store, hash-verified

128/// - Base table missing → `Err(Plan)` so users can distinguish it from an
129/// unknown system name
130pub(crate) async fn load(
131 catalog: Arc<dyn Catalog>,
132 database: String,
133 base: String,
134 system_name: String,
135) -> DFResult<Option<Arc<dyn TableProvider>>> {
136 if !is_registered(&system_name) {
137 return Ok(None);
138 }
139 let identifier = Identifier::new(database, base.clone());
140 match catalog.get_table(&identifier).await {
141 Ok(table) => {
142 if system_name.eq_ignore_ascii_case("partitions") {
143 return partitions::build(catalog, identifier, table).map(Some);
144 }
145 wrap_to_system_table(&system_name, table)
146 .expect("is_registered guarantees a builder")
147 .map(Some)
148 }
149 Err(paimon::Error::TableNotExist { .. }) => Err(DataFusionError::Plan(format!(
150 "Cannot read system table `${system_name}`: \
151 base table `{base}` does not exist"
152 ))),
153 Err(e) => Err(to_datafusion_error(e)),
154 }
155}
156
157#[cfg(test)]
158mod tests {

Callers 3

tableMethod · 0.85
read_batch_streamMethod · 0.85
load_partition_indexMethod · 0.85

Calls 6

is_registeredFunction · 0.85
wrap_to_system_tableFunction · 0.85
to_datafusion_errorFunction · 0.85
buildFunction · 0.70
PlanClass · 0.50
get_tableMethod · 0.45

Tested by

no test coverage detected