You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/09/18 10:23:54 UTC

(superset) branch master updated: fix(presto): require PyHive 0.7 for SQLAlchemy 2 (#44285)

This is an automated email from the ASF dual-hosted git repository.

aminghadersohi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new a7dab4a5519 fix(presto): require PyHive 0.7 for SQLAlchemy 2 (#44285)
a7dab4a5519 is described below

commit a7dab4a5519cfc1cbfd2e2e1c83622cc1110ccde
Author: Amin Ghadersohi <am...@gmail.com>
AuthorDate: Fri Sep 18 20:23:47 2026 +1000

    fix(presto): require PyHive 0.7 for SQLAlchemy 2 (#44285)
---
 UPDATING.md                                     |  4 ++++
 docs/src/data/databases.json                    |  1 +
 pyproject.toml                                  |  2 +-
 superset/db_engine_specs/presto.py              |  4 ++++
 tests/unit_tests/db_engine_specs/test_presto.py | 14 +++++++++++++-
 5 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/UPDATING.md b/UPDATING.md
index d3db7fa212e..ca62d1dec13 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -24,6 +24,10 @@ assists people when migrating to a new version.
 
 ## Next
 
+- The `presto` extra requires PyHive 0.7.0 or later. PyHive 0.6.5 cannot load
+  its Presto dialect under SQLAlchemy 2 because it imports `sqlalchemy.databases`.
+  Upgrade existing installations with `pip install "pyhive[presto]>=0.7.0"`.
+
 - `superset deletion-retention force-purge` now exits **1** when the target is
   blocked by a deletion rule or is not found (the messages are unchanged), so a
   scripted compliance erasure cannot mistake a refusal for a completed purge.
diff --git a/docs/src/data/databases.json b/docs/src/data/databases.json
index 01f4983c110..66c17b9fe78 100644
--- a/docs/src/data/databases.json
+++ b/docs/src/data/databases.json
@@ -7121,6 +7121,7 @@
         "categories": ["Query Engines", "Open Source"],
         "pypi_packages": ["pyhive"],
         "install_instructions": "pip install \"apache-superset[presto]\"",
+        "version_requirements": "PyHive 0.7.0 or later is required for SQLAlchemy 2. PyHive 0.6.5 imports the removed sqlalchemy.databases module.",
         "connection_string": "presto://{hostname}:{port}/{database}",
         "default_port": 8080,
         "parameters": {
diff --git a/pyproject.toml b/pyproject.toml
index 31fa0c2f182..c573ad4a276 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -256,7 +256,7 @@ parseable = ["sqlalchemy-parseable>=0.1.6,<0.2.0"]
 pinot = ["pinotdb>=5.0.0, <10.0.0"]
 playwright = ["playwright>=1.62.0, <2"]
 postgres = ["psycopg2-binary==2.9.12"]
-presto = ["pyhive[presto]>=0.6.5"]
+presto = ["pyhive[presto]>=0.7.0"]
 trino = ["trino>=0.339.0"]
 prophet = ["prophet>=1.4.0, <2"]
 # sqlalchemy-redshift cuts hard from SQLAlchemy 1.4-only (0.8.x) to 2.0-only
diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py
index ec9bd503aaf..91dac92806b 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -943,6 +943,10 @@ class PrestoEngineSpec(PrestoBaseEngineSpec):
         "categories": [DatabaseCategory.QUERY_ENGINES, DatabaseCategory.OPEN_SOURCE],
         "pypi_packages": ["pyhive"],
         "install_instructions": 'pip install "apache-superset[presto]"',
+        "version_requirements": (
+            "PyHive 0.7.0 or later is required for SQLAlchemy 2. "
+            "PyHive 0.6.5 imports the removed sqlalchemy.databases module."
+        ),
         "connection_string": "presto://{hostname}:{port}/{database}",
         "default_port": 8080,
         "parameters": {
diff --git a/tests/unit_tests/db_engine_specs/test_presto.py b/tests/unit_tests/db_engine_specs/test_presto.py
index 1a771cca5cb..0fb7e207e7f 100644
--- a/tests/unit_tests/db_engine_specs/test_presto.py
+++ b/tests/unit_tests/db_engine_specs/test_presto.py
@@ -26,7 +26,7 @@ import pytest
 import pytz
 from pyhive.sqlalchemy_presto import PrestoDialect
 from pytest_mock import MockerFixture
-from sqlalchemy import column, sql, text, types
+from sqlalchemy import column, create_engine, sql, text, types
 from sqlalchemy.engine.interfaces import Dialect
 from sqlalchemy.engine.url import make_url
 
@@ -46,6 +46,18 @@ from tests.unit_tests.db_engine_specs.utils import (
 )
 
 
+def test_dialect_loads_under_installed_sqlalchemy(mocker: MockerFixture) -> None:
+    """Pin presto:// entry point resolution and the pyformat paramstyle, without I/O."""
+    socket = mocker.patch("socket.socket", side_effect=AssertionError("Network I/O"))
+    engine = create_engine("presto://user@localhost:8080/hive/default")
+    try:
+        assert isinstance(engine.dialect, PrestoDialect)
+        assert str(text("SELECT :value").compile(engine)) == "SELECT %(value)s"
+    finally:
+        engine.dispose()
+    socket.assert_not_called()
+
+
 @pytest.mark.parametrize(
     "target_type,dttm,expected_result",
     [