Skip to content

Commit

Permalink
chore: adjust time zone approach back to legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
eakmanrq committed Sep 22, 2024
1 parent 880f0cb commit 9415ccd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tests/common_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,11 @@ def spark_session(pyspark_session: PySparkSession) -> SparkSession:

@pytest.fixture(scope="function")
def duckdb_session() -> DuckDBSession:
connection = duckdb.connect(config={"TimeZone": "UTC"})
return DuckDBSession(conn=connection)
connector = duckdb.connect()
connector.execute("set TimeZone = 'UTC'")
connector.execute("SELECT * FROM duckdb_settings() WHERE name = 'TimeZone'")
assert connector.fetchone()[1] == "UTC" # type: ignore
return DuckDBSession(conn=connector)


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/engines/duck/test_duckdb_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
def duckdb_session() -> DuckDBSession:
import duckdb

connector = duckdb.connect(config={"TimeZone": "UTC"})
connector = duckdb.connect()
connector.sql("set TimeZone = 'UTC'")
session = DuckDBSession(connector)
session._execute('''ATTACH ':memory:' AS "default"''')
session._execute('''ATTACH ':memory:' AS "catalog1"''')
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/engines/test_int_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ def test_last_day(get_session_and_func):
def test_from_unixtime(get_session_and_func):
session, from_unixtime = get_session_and_func("from_unixtime")
df = session.createDataFrame([(1428476400,)], ["unix_time"])
if isinstance(session, (BigQuerySession, DuckDBSession, PostgresSession, SnowflakeSession)):
if isinstance(session, (BigQuerySession, PostgresSession, SnowflakeSession)):
expected = "2015-04-08 07:00:00"
else:
expected = "2015-04-08 00:00:00"
Expand Down Expand Up @@ -1540,7 +1540,7 @@ def test_to_utc_timestamp(get_session_and_func):
def test_timestamp_seconds(get_session_and_func):
session, timestamp_seconds = get_session_and_func("timestamp_seconds")
df = session.createDataFrame([(1230219000,)], ["unix_time"])
if isinstance(session, (BigQuerySession, DuckDBSession, PostgresSession, SnowflakeSession)):
if isinstance(session, (BigQuerySession, PostgresSession, SnowflakeSession)):
expected = datetime.datetime(2008, 12, 25, 15, 30, 00)
else:
expected = datetime.datetime(2008, 12, 25, 7, 30)
Expand Down

0 comments on commit 9415ccd

Please sign in to comment.