-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Query events by date for properties known to be dates #7608
Conversation
…count for unparseable values
ee/clickhouse/models/property.py
Outdated
@@ -230,6 +230,18 @@ def prop_filter_json_extract( | |||
), | |||
params, | |||
) | |||
elif operator == "is_after": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update ee/clickhouse/models/test/test_property.py#TEST_PROPERTIES
This reverts commit 6ec1da8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this doesn't depend on #7500 Current state of the branch should let you query any property that ClickHouse knows how to convert as if it was a DateTime and our $time property |
This reverts commit f09ae43.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a great addition, though as a user it's pretty confusing that there are two "greater/less than" options, the second one being "after/before". I think it would be more intuitive if is_date_after
/is_date_before
were just special cases of after/before UI-side, instead of entirely separate options (e.g. for properties recognized as containing dates/times, you would have a calendar icon on the right of the usual text input, which would turn the filter into before/after).
frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
Outdated
Show resolved
Hide resolved
and prop.property_definition.format is not None | ||
and prop.property_definition.format == UNIX_TIMESTAMP_IN_SECONDS | ||
): | ||
query = f"AND parseDateTimeBestEffortOrNull(substring({property_expr}, 1, 10)) > %({prop_value_param_key})s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poking questions from an ignoramus:
What happens if property_expr
results in a non-string? What happens if the value has leading/trailing whitespace? What happens if the datetime string has 10+ characters like 2021-04-01 18:30:00
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the datetime string has 10+ characters like 2021-04-01 18:30:00
parseDateTimeBestEffortOrNull matches a range of formats or returns null. If someone sends a datetime that ClickHouse can't parse it isn't matched in the results (because null is neither greater than nor less than any date)
What happens if property_expr results in a non-string? What happens if the value has leading/trailing whitespace?
select parseDateTimeBestEffortOrNull(' 2021-12-25 00:00:01')
-- ✅ 2021-12-25 00:00:01
select parseDateTimeBestEffortOrNull(' 2021-12-25 00:00:01 ')
-- ✅ 2021-12-25 00:00:01
select parseDateTimeBestEffortOrNull(' not a date ')
-- ✅ null
select toDateTimeOrNull(' 2021-12-25 00:00:01')
-- ❌ null
select toDateTimeOrNull(' 2021-12-25 00:00:01 ')
-- ❌ null
At the point there are enough examples in the code to refactor this. I'll include a call-out to the parseDateTime docs. Since this enough is only in my head right now
frontend/src/lib/components/PropertyFilters/components/taxonomicPropertyFilterLogic.ts
Outdated
Show resolved
Hide resolved
agreed. I think the next step is to merge this and follow up with changes to property/event definitions so the UI can be type aware. And do sensible things like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me! Let's get this in
Storybook is failing outside of our control. See chromaui/chromatic-cli#485 Will merge this as the changes don't impact the story book |
Changes
First step in allowing filtering before and after a given date for the events table. When querying properties we know are dates or timestamps but are stored as strings that ClickHouse should be able to parse as DateTime
Example of querying for #6619
How did you test this code?
by adding and running tests, by running the queries manually
running the UI manually with and without the feature flag, filtering on the events table and on an insight