Skip to content

[C++][Gandiva] castTIMESTAMP_utf8 and castTIME_utf8 should truncate subseconds beyond milliseconds, not reject them #48866

@akravchukdremio

Description

@akravchukdremio

Describe the bug, including details regarding any error messages, version, and platform.

The Gandiva precompiled time casting functions (castTIMESTAMP_utf8 and castTIME_utf8) incorrectly reject timestamp and time string literals with more than 3 subsecond digits (beyond millisecond precision), instead of truncating them as other implementations do.

Current behavior:

castTIMESTAMP_utf8("2025-03-26 11:34:56.123456789")
// Returns: 0 (error)
// Error: "Invalid millis for timestamp value 2025-03-26 11:34:56.123456789"

castTIME_utf8("09:45:30.123456789")
// Returns: 0 (error)  
// Error: "Invalid millis for time value 09:45:30.123456789"

Expected behavior:

castTIMESTAMP_utf8("2025-03-26 11:34:56.123456789")
// Should return: equivalent to "2025-03-26 11:34:56.123" (truncated to milliseconds)

castTIME_utf8("09:45:30.123456789")
// Should return: equivalent to "09:45:30.123" (truncated to milliseconds)

I'm going to open PR with the fix.

Component(s)

Gandiva

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions