Skip to content

parse_decimal rejects input with leading/trailing whitespace #10793

Closed

Description

@neilconway

Describe the bug

This is inconsistent with how whitespace is handling when parsing floats, as well as the behavior when casting utf8 -> decimal.

To Reproduce

use arrow_array::types::{Decimal128Type, Float64Type};
use arrow_array::{ArrayRef, StringArray, cast::AsArray};
use arrow_cast::parse::{Parser, parse_decimal};
use arrow_cast::cast;
use arrow_schema::DataType;
use std::sync::Arc;

assert_eq!(Float64Type::parse(" 1.5"), Some(1.5));

let strings: ArrayRef = Arc::new(StringArray::from(vec![" 1.5"]));
let decimals = cast(&strings, &DataType::Decimal128(10, 1)).unwrap();
assert_eq!(decimals.as_primitive::<Decimal128Type>().value(0), 15); // 1.5

parse_decimal::<Decimal128Type>(" 1.5", 10, 1); // Err: can't parse the string value  1.5 to decimal

Expected behavior

No response

Additional context

No response

Activity

  1. added
    bug
    on Aug 21, 2026
  2. added theissue type on Aug 21, 2026
  3. neilconway commented on Aug 21, 2026

    @neilconway
    ContributorAuthor

    take

  4. Rich-T-kid commented on Aug 21, 2026

    @Rich-T-kid
    Contributor

    related : #9538

  5. added a commit that references this issue on Sep 1, 2026
    70219af
  6. added 3 commits that reference this issue on Sep 18, 2026
    f9eb4aa
    8bac2b6
    e9e1631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions