Repository navigation
Conversation
rctruta
force-pushed
the
fix/to-date-parse-error-message
branch
from
December 3, 2026 22:18
794f6c5 to
8d5f0a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
to_date(string)returns leftover "converting from i64 to i32 failed" error on unparseable strings #27841.Rationale for this change
When 1-argument
to_date(str)receives an unparseable string (such asto_date('1995-02-30'),to_date('not-a-date'), orto_date('')), it currently returns:This message is a leftover from the pre-#12227
i64nanosecond-timestamp ->i32epoch-day narrowing step;Date32Type::parse(s)parses directly toOption<i32>, so returning that message onNonemisleads users about why parsing failed and hides the offending value. ReturningError parsing '{s}' as Date32reports the actual parse failure and input string (consistent withto_time'sError parsing '{s}' as time).What changes are included in this PR?
Date32Type::parse(s) => Nonearm indatafusion/functions/src/datetime/to_date.rsto returnarrow_err!(ParseError(format!("Error parsing '{s}' as Date32"))).test_to_date_string_with_invalid_numberinto_date.rsand the invalid-date cases indatafusion/sqllogictest/test_files/datetime/dates.sltto assert the full error message across'213111111'/'202412311','1995-02-30','not-a-date', and''.What is the testing strategy for this PR?
datafusion/functions/src/datetime/to_date.rs(test_to_date_string_with_invalid_number) coveringUtf8,LargeUtf8, andUtf8Viewscalars and arrays.sqllogictestcases indatafusion/sqllogictest/test_files/datetime/dates.slt.Are there any user-facing changes?
Invalid string inputs to 1-argument
to_date()now returnArrow error: Parser error: Error parsing '<input>' as Date32instead ofArrow error: Parser error: Unable to cast to Date32 for converting from i64 to i32 failed.