Skip to content

Conversation

@mhilton
Copy link
Contributor

@mhilton mhilton commented Oct 2, 2023

Which issue does this PR close?

Closes #7697.

Rationale for this change

The specific use case for this change is to allow the third (offset) parameter of the date_bin function to be specified as a constant string when the input array for the second parameter has a specified time zone.

What changes are included in this PR?

Extend the type coercion logic used with function calls to enable text respresentaions of timestamps to be coerced to a timestamp type with a timezone. If there is no other suitable choice the timezone will be "+00" (UTC).

Are these changes tested?

Yes

Are there any user-facing changes?

Strictly speaking this changes the behaviour in a way a user might notice, not in a way that requires changes to the documentation though.

Extend the type coercion logic used with function calls to enable
text respresentaions of timestamps to be coerced to a timestamp
type with a timezone. If there is no other suitable choice the
timezone will be "+00" (UTC).

The specific use case for this change is to allow the third (offset)
parameter of the date_bin function to be specified as a constant
srting when the input array for the second parameter has a specitied
time zone.
@github-actions github-actions bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Oct 2, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mhilton -- I think this code does what it says and fixes the problem described nicely

I think the +TZ thing is a little magic and I would like to pull it into its own named constant (with a comment explaining what is going on to make that more discoverable). Maybe I can do that as a follow on PR if you prefer

Create a named constant for the placeholder timezone as suggested
in the review.
@alamb
Copy link
Contributor

alamb commented Oct 2, 2023

I made a follow on PR with some documentation and naming improvments: #7726

Ted-Jiang pushed a commit to Ted-Jiang/arrow-datafusion that referenced this pull request Oct 7, 2023
* fix: coerce text to timestamps with timezones

Extend the type coercion logic used with function calls to enable
text respresentaions of timestamps to be coerced to a timestamp
type with a timezone. If there is no other suitable choice the
timezone will be "+00" (UTC).

The specific use case for this change is to allow the third (offset)
parameter of the date_bin function to be specified as a constant
srting when the input array for the second parameter has a specitied
time zone.

* review comments

Create a named constant for the placeholder timezone as suggested
in the review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date_bin cannot use a string origin parameter when the expression has a time zone.

2 participants