Skip to content

ScalarValue::iter_to_array accepts mismatched type parameters #24538

Description

@Theodus

Describe the bug

ScalarValue::iter_to_array accepts scalars with the same enum variant but different DataType parameters. It builds the output array with the first scalar's parameters and discards the later parameters.

This affects:

  • Decimal32, Decimal64, Decimal128, and Decimal256 precision and scale
  • Timestamp timezones for every time unit
  • FixedSizeBinary widths

To Reproduce

use datafusion_common::ScalarValue;

let scalars = [
    ScalarValue::Decimal128(Some(100), 10, 2),
    ScalarValue::Decimal128(Some(100), 11, 2),
];

// This succeeds and uses precision 10 instead of returning an error.
assert!(ScalarValue::iter_to_array(scalars).is_ok());

Expected behavior

ScalarValue::iter_to_array should return an error when decimal precision, decimal scale, timestamp timezone, or fixed-size binary width differs.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions