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

feat: DateTimeOffset #546

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cliedeman
Copy link
Contributor

@cliedeman cliedeman commented Sep 9, 2024

This is my follow up to #521

Rationale:
I have many models that currently use DateTimeOffset to map entities and I would like to serialize these without creating mapping models.

I am aware that DateTimeOffset was previously removed due to confusion but I have added additional checks to try and mitigate this.

The Logical Timestamp helps with this as we can refuse to decode a Timestamp to DateTimeOffset when it is not in UTC. As this invites errors and can cause confusion. (DateTime avoids this by allowing you to stipulate the kind as Local).

try {
int longsRead = Decode(source, longs.AsSpan(0, data.Length));
if(tse.LogicalType?.TIMESTAMP is not null) {
if(!tse.LogicalType.TIMESTAMP.IsAdjustedToUTC) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This probably deserved a dedicated error and a link to the docs if this change is accepted

@cliedeman cliedeman force-pushed the feat/datetimeoffset branch 2 times, most recently from 1d3e666 to d1c16cc Compare September 9, 2024 09:01
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
protected virtual bool BaseClrTypeCompatible(DataField other) => this.BaseClrType == other.BaseClrType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hack to fix the serialization append issue I encountered.

Fundamentally the parquet thrift schema on its own does not enough information to differentiate date time offset vs date time with the class.

Will have to rethink my approach. Possibly merge DateTimeOffsetDataField into DateTimeDataField somehow

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.

1 participant