pub fn assert_schema_equal(
left_schema: &Schema,
right_schema: &Schema,
check_dtypes: bool,
check_column_order: bool,
) -> PolarsResult<()>Expand description
Compares schemas for equality based on specified criteria.
This function validates that two schemas have compatible schemas by checking column names, their order, and optionally their data types according to the provided configuration parameters.
§Arguments
left- The first schema to compareright- The second schema to comparecheck_dtypes- If true, requires data types to match for corresponding columnscheck_column_order- If true, requires columns to appear in the same order
§Returns
Ok(())if schemas match according to specified criteriaErrwith details about schema mismatches if schemas differ
§Behavior
The function performs schema validation in the following order:
- Fast path: Returns immediately if schemas are identical
- Column name validation: Ensures both schemas have the same set of column names
- Reports columns present in left but missing in right
- Reports columns present in right but missing in left
- Column order validation: If
check_column_orderis true, verifies columns appear in the same sequence - Data type validation: If
check_dtypesis true, ensures corresponding columns have matching data types- When
check_column_orderis false, compares data type sets for equality - When
check_column_orderis true, performs more precise type checking
- When