pub fn arrow_schema_from(
resut_set_metadata: &mut impl ResultSetMetadata,
map_value_errors_to_null: bool,
) -> Result<Schema, Error>Expand description
Query the metadata to create an arrow schema. This method is invoked automatically for you by
crate::OdbcReaderBuilder::build. You may want to call this method in situtation ther you want
to create an arrow schema without creating the reader yet.
ยงExample
use anyhow::Error;
use arrow_odbc::{arrow_schema_from, arrow::datatypes::Schema, odbc_api::Connection};
fn fetch_schema_for_table(
table_name: &str,
connection: &Connection<'_>
) -> Result<Schema, Error> {
// Query column with values to get a cursor
let sql = format!("SELECT * FROM {}", table_name);
let mut prepared = connection.prepare(&sql)?;
// Now that we have prepared statement, we want to use it to query metadata.
let map_errors_to_null = false;
let schema = arrow_schema_from(&mut prepared, map_errors_to_null)?;
Ok(schema)
}