Skip to content

Commit

Permalink
Add test to demonstrate inconsistent timezone handling
Browse files Browse the repository at this point in the history
- Follow up commit will fix the test
  • Loading branch information
IvoDD committed Apr 8, 2024
1 parent 74dea51 commit 7b664b8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions python/tests/unit/arcticdb/version_store/test_query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import numpy as np
import pandas as pd
import pytest
import datetime
import dateutil

from arcticdb.version_store.processing import QueryBuilder
from arcticdb.util.test import assert_frame_equal
Expand Down Expand Up @@ -60,6 +62,42 @@ def test_querybuilder_date_range_then_filter(lmdb_version_store_tiny_segment, us
assert_frame_equal(expected, received)


# TODO: This test is currently failing to demonstrate issue arcticdb-man#103. Will be fixed in followup commit
def test_querybuilder_filter_datetime_with_timezone(lmdb_version_store_tiny_segment):
lib = lmdb_version_store_tiny_segment
cnt = [0]
def can_read_back(write_with_time, filter_with_time):
symbol = f"sym_{cnt[0]}"
cnt[0] += 1

df = pd.DataFrame({"col": [write_with_time]})
lib.write(symbol, df)

q = QueryBuilder()
q = q[q["col"] == filter_with_time]
read_df = lib.read(symbol, query_builder=q).data

return len(read_df) == 1

notz_winter_time = datetime.datetime(2024, 1, 1)
notz_summer_time = datetime.datetime(2024, 6, 1)
utc_time = datetime.datetime(2024, 6, 1, tzinfo=dateutil.tz.tzutc())
us_time = datetime.datetime(2024, 6, 1, tzinfo=dateutil.tz.gettz('America/New_York'))

# Reading back the same time should always succeed
assert can_read_back(notz_winter_time, notz_winter_time)
assert can_read_back(notz_summer_time, notz_summer_time)
assert can_read_back(utc_time, utc_time)
assert can_read_back(us_time, us_time)

# If tzinfo is not specified we assume UTC
assert can_read_back(notz_summer_time, utc_time)
assert can_read_back(utc_time, notz_summer_time)
assert not can_read_back(notz_summer_time, us_time)
assert not can_read_back(us_time, notz_summer_time)



@pytest.mark.parametrize("use_date_range_clause", [True, False])
def test_querybuilder_date_range_then_project(lmdb_version_store_tiny_segment, use_date_range_clause):
lib = lmdb_version_store_tiny_segment
Expand Down

0 comments on commit 7b664b8

Please sign in to comment.