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

Feature/datetime-metadata-filters #486

Merged
merged 26 commits into from
Jun 25, 2024
Merged

Conversation

sdafni
Copy link
Collaborator

@sdafni sdafni commented Jun 3, 2024

  1. support periodic filters on datetime fields
  2. fix datetime field to be in milliseconds

backend: https://github.com/DagsHub/gogs/pull/1826

Copy link

dagshub bot commented Jun 3, 2024

@sdafni sdafni force-pushed the feature/datetime-metadata-advanced branch from 93d98bc to 4915bd3 Compare June 18, 2024 08:27
@sdafni sdafni marked this pull request as ready for review June 18, 2024 08:31
@sdafni sdafni requested a review from kbolashev June 18, 2024 08:33
Copy link
Member

@kbolashev kbolashev left a comment

Choose a reason for hiding this comment

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

Additional comments:

dagshub/data_engine/model/datasource.py Outdated Show resolved Hide resolved
dagshub/data_engine/model/datasource.py Outdated Show resolved Hide resolved
dagshub/data_engine/model/datasource.py Outdated Show resolved Hide resolved
Comment on lines 1490 to 1494
def _get_local_timezone():
now_utc = datetime.datetime.utcnow()
local_timezone = tz.tzlocal()
return now_utc.astimezone(local_timezone).strftime('%z')[:-2] + ':' + now_utc.astimezone(
local_timezone).strftime('%z')[-2:]
Copy link
Member

Choose a reason for hiding this comment

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

https://stackoverflow.com/a/61049837

shouldn't be using utcnow(), because it returns tz-unaware datetimes.
Might also break on windows, where the clock is set to localtime and not UTC.

Can you explain a bit more what this function does in general, because I'm not sure I understand it right now and it feels like there will be some tz errors inevitably

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

return a timezone offset in the form of "+03:00" or "-03:00"

"filter": {
"key": key,
"value": value if query_op is FieldFilterOperand.TIMEOFDAY else 0,
"valueRange": 0 if query_op is FieldFilterOperand.TIMEOFDAY else value,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a point to doing the valueRange thing if it can be instead represented as multiple ORs?
I don't know how the frontend would go about handling all of this though, but adding a new field in the filter just for this seems strange to me

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 could, but since in the UI there is an option to mark multiple days, its more convenient to have a single filter built at once

dagshub/data_engine/model/query.py Outdated Show resolved Hide resolved
@sdafni sdafni force-pushed the feature/datetime-metadata-advanced branch from f6aa7b1 to 21c4091 Compare June 19, 2024 11:32
@sdafni sdafni requested a review from kbolashev June 19, 2024 13:40
Copy link
Member

@kbolashev kbolashev left a comment

Choose a reason for hiding this comment

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

Almost ready to approve it, but the test timezone concerns me

tests/data_engine/test_querying.py Outdated Show resolved Hide resolved
tests/data_engine/test_querying.py Outdated Show resolved Hide resolved
@kbolashev kbolashev merged commit d991baf into master Jun 25, 2024
8 checks passed

"""
self._test_not_comparing_other_ds(item)
self._query.timezone = _get_local_timezone()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if not self._query.timezone:
self._query.timezone = _get_local_timezone()

Copy link
Member

Choose a reason for hiding this comment

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

Oops 🙃
Make a PR to fix it I guess 🤷

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