Skip to content

Conversation

@mhilton
Copy link
Contributor

@mhilton mhilton commented Oct 17, 2023

Which issue does this PR close?

Closes #7849.

Rationale for this change

Currently operations that one might reasonable expect to succeed using date_bin and mixing TIMESTAMP and TIMESTAMPTZ types error because the type coercion cannot coerce to a supported set of parameters.

What changes are included in this PR?

Add coercion rules to support coercion from timestamp types without a timezone to a timestamp with a timezone. Like with the coercion of strings or numeric constants, when a function requires the TIMEZONE_WILDCARD placeholder timezone "+00" will be used as the timezone offset.

Are these changes tested?

Yes, I have added an sqllogictest for the exact case I would like to see supported.

Are there any user-facing changes?

No

Add coercion rules to support coercion from timestamp types without
a timezone to a timestamp with a timezone. Like with the coercion
of strings or numeric constants, when a function requires the
TIMEZONE_WILDCARD placeholder timezone "+00" will be used as the
timezone offset.
@github-actions github-actions bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Oct 17, 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.

This makes sense to me -- thank you @mhilton

I suggest we also add a cast for a comparison, it is isn't there already, as I believe the code changed in this PR is only used for coercing function arguments. Something like this, perhaps:

select TIMESTAMPTZ '2022-01-01 20:10:00Z' = TIMESTAMP '2020-01-01')

Add additional SQL logic test suggested in review.
Add a positive test case for TIMESTAMPTZ and TIMESTAMP comparison.
@alamb
Copy link
Contributor

alamb commented Oct 18, 2023

Thanks again everyone

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.

Timestamps without a timezone should be able to coerce to Timestamp types with a timezone

4 participants