From 6ae4a060d506c237bf7918e99e3ecd48b4d42657 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 14 Feb 2023 11:39:20 -0500 Subject: [PATCH] fix(duckdb): explicitly set timezone to UTC on connection --- ibis/backends/duckdb/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py index d623f201bdcb..eda351cfa49e 100644 --- a/ibis/backends/duckdb/__init__.py +++ b/ibis/backends/duckdb/__init__.py @@ -138,13 +138,18 @@ def do_connect( Path(temp_directory).mkdir(parents=True, exist_ok=True) config["temp_directory"] = str(temp_directory) - super().do_connect( - sa.create_engine( - f"duckdb:///{database}", - connect_args=dict(read_only=read_only, config=config), - poolclass=sa.pool.SingletonThreadPool if in_memory else None, - ) + engine = sa.create_engine( + f"duckdb:///{database}", + connect_args=dict(read_only=read_only, config=config), + poolclass=sa.pool.SingletonThreadPool if in_memory else None, ) + + @sa.event.listens_for(engine, "connect") + def set_time_zone(dbapi_connection, connection_record): + dbapi_connection.execute("SET TimeZone = 'UTC'") + + super().do_connect(engine) + self._meta = sa.MetaData() self._extensions = set()