Skip to content

Incorrect Scalar Timezone Coercion #5952

@tustvold

Description

@tustvold

Describe the bug

The scalar coercion logic currently incorrectly interprets a timezone without a timezone qualifier as a time since the UTC epoch. It should instead interpret it as relative to the timezone it is being cast to.

To Reproduce

#5914 added the following test (known to be incorrect at the time)

query P
select arrow_cast(timestamp '2000-01-01T00:00:00', 'Timestamp(Nanosecond, Some( "+08:00" ))');
----
2000-01-01T08:00:00+08:00

Expected behavior

The correct result is

2000-01-01T00:00:00+08:00

Additional context

Following #5782 which includes the fix for apache/arrow-rs#1936 the array cast is now correct

create table foo as select '2000-01-01T00:00:00' as ts;
❯ select arrow_cast(ts, 'Timestamp(Nanosecond, Some( "+08:00" ))') from foo;
+---------------------------+
| foo.ts                    |
+---------------------------+
| 2000-01-01T00:00:00+08:00 |
+---------------------------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions