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

Better support for parsing date-related data types from ClickHouse #6863

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

bnaecker
Copy link
Collaborator

  • Support parsing timezones out of DateTime and DateTime64 types, and add support for Date type.
  • Switch to using nom for more robust parsing of these types.
  • Fix bug in block concatenation, where we concatenated rows but didn't update the contained row count. Add regression test.
  • Add a new USDT probe for data packets specifically, with size and column names / types

- Support parsing timezones out of `DateTime` and `DateTime64` types,
  and add support for `Date` type.
- Switch to using `nom` for more robust parsing of these types.
- Fix bug in block concatenation, where we concatenated rows but didn't
  update the contained row count. Add regression test.
- Add a new USDT probe for data packets specifically, with size and
  column names / types
dst.reserve(values.len() * std::mem::size_of::<u16>());
for value in values {
let days = value.signed_duration_since(EPOCH).num_days();
dst.put_u16_le(u16::try_from(days).unwrap());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We shouldn't unwrap here. We can do that when deserializing values from ClickHouse, because the range must have already been validated to fit in a u16 for ClickHouse to have stored it in the first place. These values are from us, and start as chrono::NaiveDates, which have a wider range than ClickHouse supports. We need to check that and fail this call if they're out of range.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made this and the related pieces fallible in ff0af17

@bnaecker
Copy link
Collaborator Author

Sorry to request a review and then push more commits. This is indeed ready for a review!

Copy link
Contributor

@andrewjstone andrewjstone left a comment

Choose a reason for hiding this comment

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

I have no experience with nom, but lgtm.

@bnaecker bnaecker merged commit 9ea5002 into main Oct 15, 2024
18 checks passed
@bnaecker bnaecker deleted the better-clickhouse-date-support branch October 15, 2024 17:48
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