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

Method try_new

crates/integrations/datafusion/src/table/mod.rs:62–75  ·  view source on GitHub ↗

Create a table provider from a Paimon table. Loads the table schema and converts it to Arrow for DataFusion.

(table: Table)

Source from the content-addressed store, hash-verified

60 ///
61 /// Loads the table schema and converts it to Arrow for DataFusion.
62 pub fn try_new(table: Table) -> DFResult<Self> {
63 let mut fields = table.schema().fields().to_vec();
64 let core_options = paimon::spec::CoreOptions::new(table.schema().options());
65 if core_options.data_evolution_enabled() {
66 fields.push(paimon::spec::DataField::new(
67 paimon::spec::ROW_ID_FIELD_ID,
68 paimon::spec::ROW_ID_FIELD_NAME.to_string(),
69 paimon::spec::DataType::BigInt(paimon::spec::BigIntType::with_nullable(true)),
70 ));
71 }
72 let schema =
73 paimon::arrow::build_target_arrow_schema(&fields).map_err(to_datafusion_error)?;
74 Ok(Self { table, schema })
75 }
76
77 pub fn table(&self) -> &Table {
78 &self.table

Callers

nothing calls this directly

Calls 6

to_vecMethod · 0.80
fieldsMethod · 0.45
schemaMethod · 0.45
optionsMethod · 0.45

Tested by

no test coverage detected