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

Serialize timezone in timestamp scalar values #2120

Merged
merged 3 commits into from
Mar 30, 2022

Conversation

thinkharderdev
Copy link
Contributor

Which issue does this PR close?

Closes #2116

Rationale for this change

Optional timezone was not being serialized in the standard protobuf serialization of ScalarValue

What changes are included in this PR?

Add timezone to the protobuf definitions and handle serialization/deserialization

Are there any user-facing changes?

No

No

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.

LGTM

Comment on lines +582 to +586
let timezone = if v.timezone.is_empty() {
None
} else {
Some(v.timezone.clone())
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it could be written like this:

Suggested change
let timezone = if v.timezone.is_empty() {
None
} else {
Some(v.timezone.clone())
};
let timezone = v.timezone.map(|v| Some(v.clone()))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it could be written like this:

In this case v.timezone is a String. Rather than introduce a wrapper type to make an optional string field, this is just interpreting an empty string as None.

Value::IntervalYearmonthValue(v) => Self::IntervalYearMonth(Some(*v)),
Value::IntervalDaytimeValue(v) => Self::IntervalDayTime(Some(*v)),
Value::TimestampValue(v) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

the replication is unfortunate but I see it is not something that got introduced with this PR

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Mar 29, 2022
@yjshen yjshen merged commit 91673b3 into apache:master Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScalarValue serialization loses timezone
3 participants