File tree Expand file tree Collapse file tree
sqlmesh/core/engine_adapter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import logging
44import typing as t
55
6+ from sqlglot import exp
7+
68from sqlmesh .core .engine_adapter .base_postgres import BasePostgresEngineAdapter
79from sqlmesh .core .engine_adapter .mixins import (
810 LogicalReplaceQueryMixin ,
911 PandasNativeFetchDFSupportMixin ,
1012)
1113
1214if t .TYPE_CHECKING :
13- pass
15+ from sqlmesh . core . engine_adapter . _typing import DF
1416
1517logger = logging .getLogger (__name__ )
1618
@@ -20,3 +22,16 @@ class PostgresEngineAdapter(
2022):
2123 DIALECT = "postgres"
2224 SUPPORTS_INDEXES = True
25+
26+ def _fetch_native_df (
27+ self , query : t .Union [exp .Expression , str ], quote_identifiers : bool = False
28+ ) -> DF :
29+ """
30+ `read_sql_query` when using psycopg will result on a hanging transaction that must be committed
31+
32+ https://github.com/pandas-dev/pandas/pull/42277
33+ """
34+ df = super ()._fetch_native_df (query , quote_identifiers )
35+ if not self ._connection_pool .is_transaction_active :
36+ self ._connection_pool .commit ()
37+ return df
You can’t perform that action at this time.
0 commit comments