Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TIMESTAMP_NTZ #962

Merged
merged 20 commits into from
Oct 17, 2024
Merged

Support TIMESTAMP_NTZ #962

merged 20 commits into from
Oct 17, 2024

Conversation

Tang8330
Copy link
Contributor

@Tang8330 Tang8330 commented Oct 15, 2024

Destinations

Update dialect

  • Snowflake
  • BigQuery
  • Redshift
  • Databricks
  • MSSQL

Backwards compatibility

This PR adds backwards compatibility by having a fallback format.

If the data type in the destination is created as TIMESTAMP_TZ and the values in Transfer are stored as TIMESTAMP_NTZ, then we should be returning it with the timezone locale to preserve our existing functionality.

@Tang8330 Tang8330 changed the title [WIP] Support TIMESTAMP_NTZ [Destination] Support TIMESTAMP_NTZ Oct 16, 2024
@@ -10,7 +10,7 @@ import (
type Timestamp struct{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Timestamp
  • MicroTimestamp
  • NanoTimestamp

Do not contain any timezone information.

@Tang8330 Tang8330 marked this pull request as ready for review October 16, 2024 01:15
@Tang8330 Tang8330 requested a review from a team as a code owner October 16, 2024 01:15
@Tang8330 Tang8330 changed the title [Destination] Support TIMESTAMP_NTZ Support TIMESTAMP_NTZ Oct 16, 2024
@@ -56,6 +56,8 @@ func (MSSQLDialect) DataTypeForKind(kindDetails typing.KindDetails, isPk bool) s
case typing.ETime.Kind:
switch kindDetails.ExtendedTimeDetails.Type {
case ext.TimestampTzKindType:
return "datetimeoffset"
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like before, if we received a timestamp with tz/offset info, we discarded the tz and stored it without it. Now we'll start storing the tz. Is this change going to result in ddl changes to the column type of existing columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it will. I'll migrate the tables that are in MSSQL from datetime2 -> datetimeoffset once this change is in

Copy link
Contributor Author

@Tang8330 Tang8330 Oct 16, 2024

Choose a reason for hiding this comment

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

Actually, I don't think this would impact existing columns.

If the existing column is created as datetime2, we will then tag the column as TIMESTAMP_NTZ when we decipher the output from describe table.

When we merge our in-memory columns with existing, existing will take precedence.

It is then on the SDK to discard the tz information, which it should be doing already.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay so we won't start storing the tz info for existing columns, but if a new column is created that should be tz-aware then we will store it. Seems reasonable 👍

inMemoryCol.KindDetails.ExtendedTimeDetails.Format += ext.TimezoneOffset
}
}

// Just copy over the type since the format wouldn't be present in the destination
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, we're still not copying the layout from the destination columns.

The only logic we added is that if the destination column is TIMESTAMP_TZ and the in-memory column is TIMESTAMP_NTZ, we will append a timezone offset format to the in-memory column's format (if it's set).

@Tang8330 Tang8330 merged commit c909d84 into master Oct 17, 2024
3 checks passed
@Tang8330 Tang8330 deleted the support-timestamp-ntz branch October 17, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants