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

Fix Hydrolix dates 1 #835

Merged
merged 13 commits into from
Oct 14, 2024
Merged

Fix Hydrolix dates 1 #835

merged 13 commits into from
Oct 14, 2024

Conversation

trzysiek
Copy link
Member

@trzysiek trzysiek commented Oct 3, 2024

This eliminates an error we encountered with Hydrolix.

Q3006: Unspecified database error.  clickhouse: query failed. err: code: 169, message: Key expression contains comparison between inconvertible types: DateTime64(3) and Float64 inside reqTimeSec >= 1727858503270

It's possible to compare dates and floats in Clickhouse from 2022 year, but in 2021 it wasn't possible, and Hydrolix must use some earlier version, so I created a solution which works in both scenarios

I move date parsing from Clickhouse to Quesma, removing usage of Clickhouse's parseDateTimeBestEffort(). Now we parse date ourselves, and use toDateTime64() to compare this date with date field (checked, it works fine also for fields of basic DateTime type, not DateTime64, even in Clickhouse 4 years ago). Elastic has like 50 different date formats available, so I doubt all of them are available in Clickhouse or other databases, so it's a move in the right direction, I guess.

After:
Screenshot 2024-10-06 at 17 15 22
Timestamps are fine: there's "gte": 1727858503270 in the request, which is Wed Oct 02 2024 08:41:43 GMT+0000, so histogram starts fine from 8:41:30:
Screenshot 2024-10-06 at 17 15 49

@trzysiek trzysiek force-pushed the fix-dates-2 branch 5 times, most recently from bcf4099 to 233b989 Compare October 6, 2024 18:40
@trzysiek trzysiek marked this pull request as ready for review October 6, 2024 18:40
@trzysiek trzysiek requested a review from a team as a code owner October 6, 2024 18:41
Copy link
Contributor

@jakozaur jakozaur left a comment

Choose a reason for hiding this comment

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

Great direction?

How did you find this and concluded it is Hydrolix related? I looked into log lines and just hit this error in dev env by me and Rafal.

Copy link
Contributor

@jakozaur jakozaur left a comment

Choose a reason for hiding this comment

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

We likely need more simple tests for this date logic.

if dateTime, ok := v.(string); ok {
// if it's a date, we need to parse it to Clickhouse's DateTime format
// how to check if it does not contain date math expression?
if _, err := iso8601.ParseString(dateTime); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are not using iso8601, we should drop it from dependencies.

@trzysiek
Copy link
Member Author

trzysiek commented Oct 7, 2024

Hmm, I just knew that it always used to work fine in our new version of Clickhouse, and in Hydrolix it didn't, so I:

  • googled it and found that in Clickhouse this functionality was added somewhere in 2021-2022
  • found solution that works both now and 3 years ago, implemented it and checked it indeed works in Hydrolix too.

Copy link
Contributor

@jakozaur jakozaur left a comment

Choose a reason for hiding this comment

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

Please use int64 instead of float64. IDeally use:
fromUnixTimestamp64Milli

@trzysiek trzysiek marked this pull request as draft October 8, 2024 11:09
@jakozaur jakozaur marked this pull request as ready for review October 14, 2024 07:35
Copy link
Contributor

@jakozaur jakozaur left a comment

Choose a reason for hiding this comment

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

Applied my changes to use int64 instead of float64.

@trzysiek trzysiek added this pull request to the merge queue Oct 14, 2024
Merged via the queue into main with commit 939452c Oct 14, 2024
5 checks passed
@trzysiek trzysiek deleted the fix-dates-2 branch October 14, 2024 12:52
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