project_schema_safe

Function project_schema_safe 

Source
pub fn project_schema_safe(
    schema: &SchemaRef,
    projection: Option<&Vec<usize>>,
) -> Result<SchemaRef>
Expand description

Project a schema safely, taking into account empty columns.

When DataFusion executes queries like COUNT(*), it passes an empty projection (Some([])) indicating no columns are needed. This function returns an empty schema in that case, as DataFusion only needs row counts, not column values.

The underlying SQL still generates SELECT 1 FROM table for ClickHouse, but the RecordBatchStream schema correctly reflects that no column data is accessed.

ยงErrors

  • Returns an error if the schema projection fails