MCPcopy Create free account
hub / github.com/apache/datafusion / project_schema

Function project_schema

datafusion/common/src/utils/mod.rs:82–91  ·  view source on GitHub ↗

Applies an optional projection to a [`SchemaRef`], returning the projected schema Example: ``` use arrow::datatypes::{DataType, Field, Schema, SchemaRef}; use datafusion_common::project_schema; // Schema with columns 'a', 'b', and 'c' let schema = SchemaRef::new(Schema::new(vec![ Field::new("a", DataType::Int32, true), Field::new("b", DataType::Int64, true), Field::new("c", DataType::Utf8, true)

(
    schema: &SchemaRef,
    projection: Option<&impl AsRef<[usize]>>,
)

Source from the content-addressed store, hash-verified

80/// assert_eq!(projected_schema, expected_schema);
81/// ```
82pub fn project_schema(
83 schema: &SchemaRef,
84 projection: Option<&impl AsRef<[usize]>>,
85) -> Result<SchemaRef> {
86 let schema = match projection {
87 Some(columns) => Arc::new(schema.project(columns.as_ref())?),
88 None => Arc::clone(schema),
89 };
90 Ok(schema)
91}
92
93/// Extracts a row at the specified index from a set of columns and stores it in the provided buffer.
94pub fn extract_row_at_idx_to_buf(

Callers 11

newMethod · 0.85
compute_propertiesMethod · 0.85
try_newMethod · 0.85
compute_propertiesMethod · 0.85
compute_propertiesMethod · 0.85
try_newMethod · 0.85
newMethod · 0.85
scanMethod · 0.85
scan_with_argsMethod · 0.85
scanMethod · 0.85

Calls 3

newFunction · 0.85
projectMethod · 0.45
as_refMethod · 0.45

Tested by 3

try_newMethod · 0.68
newMethod · 0.68
scanMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…