Skip to content

Commit 160e382

Browse files
rusackasSuperset Devclaude
committed
feat(ci): expand testcontainers coverage to mariadb, timescaledb, yugabytedb, monetdb, mongodb (#43640)
Co-authored-by: Superset Dev <dev@superset.apache.org> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2b56bbf commit 160e382

17 files changed

Lines changed: 1277 additions & 12 deletions

File tree

‎.github/workflows/testcontainers.yml‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
paths:
2121
- ".github/workflows/testcontainers.yml"
2222
- "tests/testcontainers/**"
23+
- "superset/db_engine_specs/**"
24+
- "pyproject.toml"
25+
- "requirements/development.in"
26+
- "requirements/development.txt"
2327

2428
concurrency:
2529
# Scoped by ref, not just workflow name -- otherwise every PR run and the
@@ -58,6 +62,27 @@ jobs:
5862
timeout: 15
5963
- dialect: db2
6064
timeout: 25
65+
- dialect: mariadb
66+
timeout: 10
67+
- dialect: timescaledb
68+
timeout: 10
69+
- dialect: yugabytedb
70+
timeout: 10
71+
- dialect: monetdb
72+
timeout: 10
73+
- dialect: mongodb
74+
timeout: 10
75+
- dialect: postgres
76+
timeout: 10
77+
- dialect: mysql
78+
timeout: 10
79+
- dialect: clickhouse
80+
timeout: 10
81+
# StarRocks' allin1-ubuntu image brings up both FE and BE in one
82+
# container, which is a heavier bring-up than a single-process
83+
# database -- wider margin until real CI data says otherwise.
84+
- dialect: starrocks
85+
timeout: 15
6186
timeout-minutes: ${{ matrix.timeout }}
6287
env:
6388
PYTHONPATH: ${{ github.workspace }}

‎pyproject.toml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ impala = ["impyla>=0.24.0, <0.25"]
222222
# superset/db_engine_specs/kusto.py's known_incompatibilities metadata.
223223
kusto = ["sqlalchemy-kusto>=3.1.2, <4"]
224224
kylin = ["kylinpy>=2.8.4, <2.9"]
225+
# MariaDB is a MySQL fork implementing the same wire protocol - connects via
226+
# the plain mysql dialect, same driver as mysql.
227+
mariadb = ["apache-superset[mysql]"]
228+
monetdb = ["sqlalchemy-monetdb>=2.1.0, <3", "pymonetdb>=1.9.1, <2"]
229+
mongodb = ["pymongosql>=0.7.3, <1"]
225230
mssql = ["pymssql>=2.3.13, <3"]
226231
# motherduck is an alias for duckdb - MotherDuck works via the duckdb driver
227232
motherduck = ["apache-superset[duckdb]"]
@@ -270,13 +275,19 @@ tdengine = [
270275
"taos-ws-py>=0.7.0"
271276
]
272277
teradata = ["teradatasql>=20.0.0.66"]
278+
# TimescaleDB is a genuine Postgres extension, not a fork - connects via the
279+
# plain postgresql dialect, same driver as postgres.
280+
timescaledb = ["apache-superset[postgres]"]
273281
thumbnails = [] # deprecated, will be removed in 7.0
274282
vertica = ["sqlalchemy-vertica-python>= 0.6.3, < 0.7"]
275283
netezza = ["nzalchemy>= 11.1.2, < 11.2"]
276284
starrocks = ["starrocks>=1.3.4, <2"]
277285
doris = ["pydoris>=1.2.0, <2.0.0"]
278286
oceanbase = ["oceanbase_py>=0.0.1.2"]
279287
ydb = ["ydb-sqlalchemy>=0.1.22", "ydb-sqlglot-plugin>=0.2.8"]
288+
# YugabyteDB's YSQL layer is fully Postgres-wire compatible - connects via
289+
# the plain postgresql dialect, same driver as postgres.
290+
yugabytedb = ["apache-superset[postgres]"]
280291
development = [
281292
# no bounds for apache-superset-extensions-cli until a stable version
282293
"apache-superset-extensions-cli",

‎requirements/development.in‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
#
19-
-e .[development,bigquery,cockroachdb,crate,druid,duckdb,elasticsearch,fastmcp,gevent,gsheets,mssql,mysql,oracle,postgres,presto,prophet,trino,thumbnails]
19+
-e .[development,bigquery,clickhouse,cockroachdb,crate,druid,duckdb,elasticsearch,fastmcp,gevent,gsheets,monetdb,mongodb,mssql,mysql,oracle,postgres,presto,prophet,starrocks,trino,thumbnails]
2020
-e ./superset-extensions-cli[test]
2121
# testcontainers-backed db_engine_specs tests (tests/testcontainers/) --
2222
# see .github/workflows/testcontainers.yml
@@ -26,4 +26,15 @@
2626
# including it here breaks the multi-platform (amd64+arm64) dev Docker
2727
# image build. The testcontainers CI job installs it on demand, only for
2828
# the db2 matrix leg -- see .github/workflows/testcontainers.yml.
29-
testcontainers[cockroachdb,cratedb,db2,mssql,oracle,trino]>=4.15.0,<5
29+
#
30+
# mariadb/timescaledb/yugabytedb need no testcontainers extra of their own:
31+
# they reuse the postgres/mysql container classes pointed at a different
32+
# image, and psycopg2-binary/mysqlclient are already pulled in above via
33+
# the postgres/mysql extras. Plain postgres/mysql obviously need nothing
34+
# extra either. clickhouse and starrocks also need no testcontainers extra:
35+
# ClickHouseContainer has no driver import of its own (clickhouse-connect,
36+
# pulled in above via the clickhouse extra, is all the test needs), and
37+
# StarRocks has no dedicated testcontainers module at all -- its test uses
38+
# a generic DockerContainer plus the same mysqlclient the mysql extra
39+
# already provides.
40+
testcontainers[cockroachdb,cratedb,mongodb,mssql,mysql,oracle,postgres,trino]>=4.15.0,<5

‎requirements/development.txt‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ alembic==1.15.2
1616
# via
1717
# -c requirements/base-constraint.txt
1818
# flask-migrate
19+
# starrocks
1920
amqp==5.3.1
2021
# via
2122
# -c requirements/base-constraint.txt
@@ -24,6 +25,8 @@ annotated-types==0.7.0
2425
# via
2526
# -c requirements/base-constraint.txt
2627
# pydantic
28+
antlr4-python3-runtime==4.13.2
29+
# via pymongosql
2730
anyio==4.11.0
2831
# via
2932
# httpx
@@ -42,6 +45,8 @@ apsw==3.50.1.0
4245
# shillelagh
4346
astroid==3.3.10
4447
# via pylint
48+
asyncmy2==0.2.21
49+
# via starrocks
4550
attrs==25.3.0
4651
# via
4752
# -c requirements/base-constraint.txt
@@ -65,6 +70,7 @@ backports-tarfile==1.2.0
6570
backports-zstd==1.6.0
6671
# via
6772
# -c requirements/base-constraint.txt
73+
# clickhouse-connect
6874
# flask-compress
6975
bcrypt==4.3.0
7076
# via
@@ -117,6 +123,7 @@ celery==5.6.3
117123
certifi==2026.5.20
118124
# via
119125
# -c requirements/base-constraint.txt
126+
# clickhouse-connect
120127
# elasticsearch
121128
# httpcore
122129
# httpx
@@ -162,6 +169,8 @@ click-repl==0.3.0
162169
# via
163170
# -c requirements/base-constraint.txt
164171
# celery
172+
clickhouse-connect==1.7.2
173+
# via apache-superset
165174
cmdstanpy==1.1.0
166175
# via prophet
167176
colorama==0.4.6
@@ -193,6 +202,7 @@ cryptography==50.0.0
193202
# oracledb
194203
# paramiko
195204
# pyjwt
205+
# pymysql
196206
# pyopenssl
197207
# secretstorage
198208
cycler==0.12.1
@@ -221,6 +231,7 @@ dnspython==2.7.0
221231
# via
222232
# -c requirements/base-constraint.txt
223233
# email-validator
234+
# pymongo
224235
docker==7.2.0
225236
# via
226237
# apache-superset
@@ -436,10 +447,6 @@ humanize==4.12.3
436447
# via
437448
# -c requirements/base-constraint.txt
438449
# apache-superset
439-
ibm-db==3.3.0
440-
# via ibm-db-sa
441-
ibm-db-sa==0.4.4
442-
# via testcontainers
443450
identify==2.5.36
444451
# via pre-commit
445452
idna==3.15
@@ -488,6 +495,7 @@ jmespath==1.1.0
488495
# via
489496
# boto3
490497
# botocore
498+
# pymongosql
491499
joserfc==1.7.2
492500
# via fastmcp-slim
493501
jsonpath-ng==1.8.0
@@ -520,14 +528,18 @@ kombu==5.6.2
520528
# via
521529
# -c requirements/base-constraint.txt
522530
# celery
531+
lark==1.3.1
532+
# via starrocks
523533
lazy-object-proxy==1.10.0
524534
# via openapi-spec-validator
525535
limits==5.1.0
526536
# via
527537
# -c requirements/base-constraint.txt
528538
# flask-limiter
529539
lz4==4.4.5
530-
# via trino
540+
# via
541+
# clickhouse-connect
542+
# trino
531543
mako==1.4.1
532544
# via
533545
# -c requirements/base-constraint.txt
@@ -803,10 +815,24 @@ pyjwt==2.13.0
803815
# mcp
804816
pylint==3.3.7
805817
# via apache-superset
818+
pymonetdb==1.9.1
819+
# via
820+
# apache-superset
821+
# sqlalchemy-monetdb
822+
pymongo==4.17.0
823+
# via
824+
# pymongosql
825+
# testcontainers
826+
pymongosql==0.7.3
827+
# via apache-superset
806828
pymssql==2.3.13
807829
# via
808830
# apache-superset
809831
# testcontainers
832+
pymysql==1.2.0
833+
# via
834+
# starrocks
835+
# testcontainers
810836
pynacl==1.6.2
811837
# via
812838
# -c requirements/base-constraint.txt
@@ -994,14 +1020,15 @@ sqlalchemy==2.0.52
9941020
# elasticsearch-dbapi
9951021
# flask-appbuilder
9961022
# flask-sqlalchemy
997-
# ibm-db-sa
9981023
# marshmallow-sqlalchemy
9991024
# shillelagh
10001025
# sqlalchemy-bigquery
10011026
# sqlalchemy-cockroachdb
10021027
# sqlalchemy-continuum
10031028
# sqlalchemy-cratedb
1029+
# sqlalchemy-monetdb
10041030
# sqlalchemy-utils
1031+
# starrocks
10051032
# testcontainers
10061033
sqlalchemy-bigquery==1.17.2
10071034
# via apache-superset
@@ -1015,6 +1042,8 @@ sqlalchemy-cratedb==0.43.1
10151042
# via
10161043
# apache-superset
10171044
# testcontainers
1045+
sqlalchemy-monetdb==2.1.0
1046+
# via apache-superset
10181047
sqlalchemy-utils==0.42.1
10191048
# via
10201049
# -c requirements/base-constraint.txt
@@ -1038,6 +1067,8 @@ starlette==1.3.1
10381067
# via
10391068
# fastmcp-slim
10401069
# mcp
1070+
starrocks==1.3.4
1071+
# via apache-superset
10411072
statsd==4.0.1
10421073
# via apache-superset
10431074
syntaqlite==0.9.0
@@ -1113,6 +1144,7 @@ urllib3==2.7.0
11131144
# via
11141145
# -c requirements/base-constraint.txt
11151146
# botocore
1147+
# clickhouse-connect
11161148
# crate
11171149
# docker
11181150
# elasticsearch

‎superset/db_engine_specs/__init__.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from flask import current_app as app
4242
from sqlalchemy.engine.default import DefaultDialect
4343
from sqlalchemy.exc import NoSuchModuleError
44+
from sqlalchemy.sql import compiler as sqla_compiler
4445

4546
from superset import feature_flag_manager
4647
from superset.db_engine_specs.base import BaseEngineSpec
@@ -159,6 +160,16 @@ def get_available_engine_specs() -> dict[type[BaseEngineSpec], set[str]]: # noq
159160
continue
160161

161162
# installed 3rd-party dialects
163+
#
164+
# `ep.load()` runs arbitrary module-level code in the third-party package.
165+
# Some dialects (e.g. sqlalchemy-monetdb) mutate SQLAlchemy's shared,
166+
# process-global `compiler.OPERATORS` mapping in place on import instead
167+
# of subclassing it, which would otherwise silently change SQL rendering
168+
# (e.g. `!=` -> `<>`) for every dialect for the rest of the process, not
169+
# just the misbehaving one. Snapshot/restore around each load so a
170+
# buggy connector can't leak global compiler state into unrelated
171+
# dialects just because it was enumerated here.
172+
operators_snapshot = dict(sqla_compiler.OPERATORS)
162173
for ep in entry_points(group="sqlalchemy.dialects"):
163174
try:
164175
dialect = ep.load()
@@ -193,6 +204,10 @@ def get_available_engine_specs() -> dict[type[BaseEngineSpec], set[str]]: # noq
193204
if isinstance(driver, bytes):
194205
driver = driver.decode()
195206
drivers[backend].add(driver)
207+
finally:
208+
if sqla_compiler.OPERATORS != operators_snapshot:
209+
sqla_compiler.OPERATORS.clear()
210+
sqla_compiler.OPERATORS.update(operators_snapshot)
196211

197212
dbs_denylist = app.config["DBS_AVAILABLE_DENYLIST"]
198213
if not feature_flag_manager.is_feature_enabled("ENABLE_SUPERSET_META_DB"):

‎superset/db_engine_specs/clickhouse.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from typing import Any, cast, TYPE_CHECKING
2323
from urllib import parse
2424

25-
from flask import current_app as app
25+
from flask import current_app as app, has_app_context
2626
from flask_babel import gettext as __
2727
from marshmallow import fields, Schema
2828
from marshmallow.validate import Range
@@ -366,9 +366,16 @@ class ClickHouseParametersSchema(Schema):
366366
"*Int128",
367367
"string",
368368
)
369+
# Importing this module happens as a side effect of iterating db_engine_specs
370+
# (e.g. from a standalone script or test that never builds a Flask app), so
371+
# `current_app` may not be bound to an app context yet -- guard the version
372+
# lookup rather than let that crash the import outright.
373+
version_string = (
374+
app.config.get("VERSION_STRING", "dev") if has_app_context() else "dev"
375+
)
369376
set_setting(
370377
"product_name",
371-
f"superset/{app.config.get('VERSION_STRING', 'dev')}",
378+
f"superset/{version_string}",
372379
)
373380
except ImportError: # ClickHouse Connect not installed, do nothing
374381
pass

‎tests/testcontainers/db_engine_specs/_pagination.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@
2626
Each call site keeps its own test function (and dialect-specific docstring)
2727
so failures still report against the right module; this only factors out
2828
the identical table setup/assert body, via an optional post-insert hook for
29-
dialects (CrateDB) that need one.
29+
dialects (CrateDB) that need one, and an optional extra-table-args hook for
30+
dialects (ClickHouse) whose CREATE TABLE requires a schema item a plain
31+
Column/primary key can't express.
3032
"""
3133

3234
from collections.abc import Callable
35+
from typing import Any
3336

3437
from sqlalchemy import Column, insert, Integer, MetaData, select, Table as SATable
3538
from sqlalchemy.engine import Connection, Engine
@@ -38,12 +41,19 @@
3841
def assert_paginated_query_returns_correct_rows_in_order(
3942
engine: Engine,
4043
after_insert: Callable[[Connection], None] | None = None,
44+
extra_table_args: tuple[Any, ...] = (),
4145
) -> None:
4246
metadata = MetaData()
4347
t = SATable(
4448
"pilot_pagination",
4549
metadata,
46-
Column("id", Integer, primary_key=True),
50+
# autoincrement=False: a single-column integer primary key otherwise
51+
# implicitly becomes AUTO_INCREMENT on MySQL/MariaDB. That column
52+
# type treats an explicit 0 as NULL by default (NO_AUTO_VALUE_ON_ZERO
53+
# is off), so the id=0 row below would silently get auto-assigned 1,
54+
# colliding with the explicit id=1 row in the same batch insert.
55+
Column("id", Integer, primary_key=True, autoincrement=False),
56+
*extra_table_args,
4757
)
4858
metadata.create_all(engine)
4959
with engine.begin() as conn:

0 commit comments

Comments
 (0)