Skip to content

fix: casting list to fixedsizelist didn't respect input length - #10228

Merged
alamb merged 1 commit into
apache:mainfrom
Jefffrey:degenerate-fsl-cast
Jun 29, 2026
Merged

alamb merged 1 commit into
apache:mainfrom
Jefffrey:degenerate-fsl-cast

Conversation

@Jefffrey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

When casting from list[view] to degenerate fixedsizelist (0 size), if output has no nulls then it'll incorrectly output an array of length 0 which is mismatched with input array length. This can cause problems for downstream like DataFusion, since they expect input length = output length for cast kernel.

What changes are included in this PR?

Special path for degenerate fixedsizelist cast if we don't have a null buffer to infer length from.

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jun 28, 2026
Comment on lines -72 to -82
pub(crate) fn cast_values_to_fixed_size_list(
array: &dyn Array,
to: &FieldRef,
size: i32,
cast_options: &CastOptions,
) -> Result<ArrayRef, ArrowError> {
let values = cast_with_options(array, to.data_type(), cast_options)?;
let list = FixedSizeListArray::try_new(to.clone(), size, values, None)?;
Ok(Arc::new(list))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a drive-by refactor; I inlined it where it's used because it was slightly confusing that the docstring stated its for size 1 (and indeed at its only usage size is only 1) but we accept an arbitrary size

@Jefffrey Jefffrey changed the title Fix cast error when casting list to fixedsizelist didn't respect input length fix: casting list to fixedsizelist didn't respect input length Jun 28, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

@alamb
alamb merged commit e625a3f into apache:main Jun 29, 2026
31 checks passed
@Jefffrey
Jefffrey deleted the degenerate-fsl-cast branch June 29, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

casting list to 0-size fixedsizelist can cause incorrect output length

2 participants