Skip to content

Commit 28e0c96

Browse files
Apply suggestion from @AndreasAlbertQC
1 parent 54466d8 commit 28e0c96

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

dataframely/schema.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,13 @@ def cast(
816816

817817
def _cast_to_schema(
818818
lf: pl.LazyFrame, schema: dict[str, pl.DataType]
819-
) -> pl.LazyFrame:
819+
# NOTE: This function does almost the same thing as `match_to_schema`, except:
820+
#
821+
# 1. It raises a polars `polars.exceptionsColumnNotFoundError` on missing columns,
822+
# while `match_to_schema` raises a `dataframely.exc.SchemaError`
823+
# 2. The error is raised only at collection time, while `match_to_schema` raises immediately
824+
#
825+
# This behavior is needed to not break backward compatibility.
820826
return lf.select(cls.column_names()).cast(
821827
{
822828
name: col.dtype

0 commit comments

Comments
 (0)