Skip to content

Issue using arrow_cast in ORDER BY expressions #9143

@universalmind303

Description

@universalmind303

Describe the bug

originally opened in GlareDB/glaredb#2597

It seems that arrow_cast's special handling makes it so that it errors out when using it in an ORDER BY expr

To Reproduce

statement ok
create table ts (a int);

statement ok
insert into ts values (915148800);

# this errors
statement ok 
SELECT
  DATE_TRUNC('minute', arrow_cast(a, 'Timestamp(Second, None)')) AS minute
FROM
  ts
ORDER BY
  DATE_TRUNC('minute', arrow_cast(a, 'Timestamp(Second, None)'));

Expected behavior

It should be functionally equivalent in this example to using to_timestamp_seconds

SELECT
  DATE_TRUNC('minute', to_timestamp_seconds(a)) AS minute
FROM
  ts
ORDER BY
  DATE_TRUNC('minute', to_timestamp_seconds(a));

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions