@@ -25,33 +25,22 @@ use crate::scalar_fn::fns::cast::Cast;
2525///
2626/// # Nullability
2727///
28- /// A cast to a non-nullable dtype **must** fail when the array has a null row. A rule runs in the
29- /// optimizer and cannot execute, so it cannot count the nulls of a validity array. A rule that
30- /// removes nullability takes one of two forms:
28+ /// A cast to a non-nullable dtype **must** fail when the array has a null row. A rule cannot
29+ /// execute, so it handles this in one of two ways:
3130///
32- /// - **The rule builds the new validity.** The rules of [`Primitive`] and [`Decimal`] build a new
33- /// [`Validity`] for their result. Such a rule **must** call
34- /// [`Validity::trivially_cast_nullability`] and return `Ok(None)` when that call returns
35- /// `Ok(None)`. The encoding then also implements [`CastKernel`], which checks the nulls at
36- /// execution with [`Validity::cast_nullability`].
37- /// - **The rule pushes the cast into its children.** The rules of FoR and DecimalByteParts cast the
38- /// children that hold their validity and rebuild themselves over the results. The casts of the
39- /// children check the nulls, so the rule needs no check of its own. This form **requires** that
40- /// each null in those children appears as a null row of the array, and that each null row of
41- /// the array comes from a null in those children.
31+ /// - It builds a new [`Validity`], as [`Primitive`] does. It **must** return `Ok(None)` when
32+ /// [`Validity::trivially_cast_nullability`] does, and the encoding implements [`CastKernel`] for
33+ /// that case.
34+ /// - It pushes the cast into the children that hold its validity, as FoR does, and the casts of
35+ /// those children check the nulls. Every null in those children **must** reach a row of the
36+ /// array. The values of [`Dict`] break this with nulls that no code references.
4237///
43- /// [`Dict`] does not meet the requirement of the second form. Its values can hold nulls that no
44- /// code references, so a cast of the values can fail for a dictionary without null rows. The rule
45- /// of [`Dict`] proves that the values have no nulls before it pushes a cast to non-nullable.
46- ///
47- /// [`test_cast_conformance`] checks both forms when it receives a partially valid array.
38+ /// [`test_cast_conformance`] checks both forms with a partially valid array.
4839///
4940/// [`Primitive`]: crate::arrays::Primitive
50- /// [`Decimal`]: crate::arrays::Decimal
5141/// [`Dict`]: crate::arrays::Dict
5242/// [`Validity`]: crate::validity::Validity
5343/// [`Validity::trivially_cast_nullability`]: crate::validity::Validity::trivially_cast_nullability
54- /// [`Validity::cast_nullability`]: crate::validity::Validity::cast_nullability
5544/// [`test_cast_conformance`]: crate::compute::conformance::cast::test_cast_conformance
5645pub trait CastReduce : VTable {
5746 fn cast ( array : ArrayView < ' _ , Self > , dtype : & DType ) -> VortexResult < Option < ArrayRef > > ;
0 commit comments