Repository navigation
feat(ci): expand testcontainers coverage to mariadb, timescaledb, yugabytedb, monetdb, mongodb - #43640
Conversation
…abytedb, monetdb, mongodb Adds five more dialects to the testcontainers suite, stacked on top of the 7-dialect pilot in feat/testcontainers-nightly-pilot: mariadb, timescaledb, yugabytedb, monetdb, mongodb. mariadb, timescaledb, and yugabytedb are all wire-compatible with an existing base dialect (MySQL and Postgres respectively), so they reuse testcontainers' MySqlContainer/PostgresContainer classes pointed at a different image rather than needing new container-class wiring. yugabytedb specifically cannot reuse PostgresContainer's built-in readiness check, though: that execs `psql`, which the yugabyte image doesn't ship (only its own `ysqlsh`) -- uses a generic DockerContainer instead, started via `yugabyted start` and waiting on its own final startup log line. monetdb has no native testcontainers module; uses a generic DockerContainer with the documented MDB_* environment variables. Publishes an amd64-only image (confirmed running under Rosetta/QEMU emulation on Apple Silicon, unlike CrateDB's harder x86-64-v3 CPU requirement). mongodb needed a different data-setup approach, like elasticsearch before it: documents get inserted via the native pymongo driver, not SQL INSERT, since MongoDB is schemaless and Superset talks to it through pymongosql (a SQL-to-MongoDB translation layer requiring a `?mode=superset` query param). Two real bugs surfaced writing this one: testcontainers' MongoDbContainer.get_connection_url() has no database path or query string at all, so naively appending "&mode=superset" glued directly onto the port number instead of starting a query string; and the root user MongoDbContainer creates lives in the `admin` database, so connecting with a different default database in the URL requires authSource=admin or authentication fails outright. Confirmed pymongosql supports OFFSET (maps to MongoDB's native `skip`), unlike Elasticsearch's SQL layer. mariadb could not be verified locally in this environment: mysqlclient (MySQLdb) has a pre-existing, unrelated native-library linking issue against this machine's Homebrew-installed libmysqlclient. CI installs it via apt on Linux, where this does not occur -- same accepted pattern already used for crate/mssql/db2 in the base branch.
|
Bito Automatic Review Skipped - Branch Excluded |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/testcontainers-nightly-pilot #43640 +/- ##
==================================================================
Coverage 79.17% 79.17%
==================================================================
Files 2879 2879
Lines 165819 165825 +6
Branches 38330 38331 +1
==================================================================
+ Hits 131291 131298 +7
+ Misses 32055 32054 -1
Partials 2473 2473
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The flagged issue is correct. Including Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well? requirements/development.in |
MySqlContainer.get_connection_url() has no host override and defaults to get_container_host_ip(), which returns the literal string "localhost" on native Linux Docker (e.g. GitHub Actions runners). MySQLdb (mysqlclient) treats a "localhost" host specially and attempts a Unix socket connection instead of TCP, which fails since there's no local MySQL socket -- the container is only reachable over the network. Confirmed on a real GHA run: "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'". This was never caught locally because of the separate, unrelated mysqlclient linking issue on this dev machine, which crashed before ever reaching a real connection attempt.
create_all() defaults to checkfirst=True, silently skipping creation (and leaving old rows behind) if the table already exists from a prior run, which collided with the fresh id=0-9 insert on primary key for mariadb.
…t's id column A single-column integer primary key implicitly becomes AUTO_INCREMENT on MySQL/MariaDB. That column type treats an explicit 0 as NULL by default, so inserting id=0 got silently reassigned to 1, colliding with the explicit id=1 row in the same batch insert -- reproduced locally against a real mariadb:11 container and confirmed fixed with autoincrement=False. Supersedes the previous (incorrect) guess that a leftover table from an earlier run was the cause.
… mariadb host, mongodb pagination test, weak type assertions, monetdb readiness, and CI path coverage - drop `db2` from the `testcontainers[...]` extra in development.in/.txt: it transitively pulls `ibm-db-sa`/`ibm-db` into the baseline dev lockfile, which has no Linux arm64 wheel and breaks the multi-platform dev Docker image build; the db2 CI leg already installs it on demand separately. - mariadb: preserve a remote Docker daemon's real host, only rewrite the literal "localhost" case to 127.0.0.1. - testcontainers.yml: widen pull_request paths to superset/db_engine_specs/**, pyproject.toml, and the requirements manifests so a driver/lockfile-only change can't bypass this coverage. - mongodb: use Core `select(...).limit().offset()` instead of a literal SQL string, so the pagination test actually exercises the dialect's own compilation. - monetdb/mongodb/yugabytedb: assert generic_type/sqla_type on the mapped column spec, not just that a spec was returned. - monetdb: wait for the exposed port (not just a log line that predates `monetdbd start -n`) before considering the container ready. - timescaledb: pin the image to a specific tag instead of the mutable `latest-pg16`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ng global compiler state sqlalchemy-monetdb mutates SQLAlchemy's shared, process-global compiler.OPERATORS mapping in place on import instead of subclassing it (OPERATORS = compiler.OPERATORS; OPERATORS[operators.ne] = " <> "). Once Superset's own get_available_engine_specs() enumerates the "monetdb" sqlalchemy.dialects entry point to build the "available databases" list (which happens on every app boot, not just when MonetDB is actually used), that changes `!=` rendering to `<>` for every dialect for the rest of the process -- breaking test_where_operators identically across the test-mysql/test-postgres/test-sqlite CI jobs, since installing the monetdb extra now pulls sqlalchemy-monetdb into their shared dev requirements. Snapshot/restore sqlalchemy.sql.compiler.OPERATORS around each third-party dialect entry point load so a misbehaving connector can't leak global compiler state just because it was enumerated here. Also fix the new mongodb testcontainers pagination test: pymongosql's SQL-to-Mongo AST parser reads LIMIT/OFFSET off the compiled SQL text ahead of parameter substitution, so a bound `LIMIT ?`/`OFFSET ?` placeholder is silently dropped. Compile with literal_binds=True instead, matching how Superset actually issues chart/SQL Lab queries. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…test text() has no static column metadata of its own -- the row's key comes entirely from whatever pymongosql's DBAPI cursor reports for the raw compiled SQL string, which turned out to be the qualified "pilot_pagination.id" (matching the SELECT list's column reference), not the bare "id" that attribute access expected. Reproduced by compiling the exact statement offline and inspecting text()'s (empty) column metadata; confirmed the AttributeError on real CI runs of this branch and #43640.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ion test
The previous fix (positional row access) only masked the symptom.
Root cause: SQLAlchemy always qualifies a Table-bound column as
"pilot_pagination.id" once there's a FROM clause, but pymongosql's
projection builder takes that qualified text completely literally as a
MongoDB field path -- {"pilot_pagination.id": 1} reads a *nested* field
under a top-level "pilot_pagination" key, which doesn't exist on these
flat documents, silently projecting None for every row instead of
raising (confirmed via pymongosql/sql/query_handler.py's
_extract_field_and_alias, which uses the raw expression text verbatim
as the Mongo field key regardless of any AS alias).
A bare column()/table() pair (not bound to each other via a real Table
object) compiles to an unqualified "id" reference, which resolves
correctly, while still exercising the dialect's own LIMIT/OFFSET
compilation through a real Core select() -- this test's actual intent.
…test text() has no static column metadata of its own -- the row's key comes entirely from whatever pymongosql's DBAPI cursor reports for the raw compiled SQL string, which turned out to be the qualified "pilot_pagination.id" (matching the SELECT list's column reference), not the bare "id" that attribute access expected. Reproduced by compiling the exact statement offline and inspecting text()'s (empty) column metadata; confirmed the AttributeError on real CI runs of this branch and #43640.
…se, starrocks (#43652) Co-authored-by: Superset Dev <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
…abytedb, monetdb, mongodb (#43640) Co-authored-by: Superset Dev <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
…abytedb, monetdb, mongodb (#43640) Co-authored-by: Superset Dev <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
…abytedb, monetdb, mongodb (#43640) Co-authored-by: Superset Dev <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
…abytedb, monetdb, mongodb (#43640) Co-authored-by: Superset Dev <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
SUMMARY
Stacked on #43502 (the 7-dialect testcontainers pilot) — adds 5 more dialects from the docs-supported list:
mariadb,timescaledb,yugabytedb,monetdb,mongodb. All 5 verified locally against real containers exceptmariadb(mysqlclient has a pre-existing, unrelated native-library issue on this dev machine's Homebrew setup — same accepted CI-only-verification pattern already used for crate/mssql/db2 in the base branch).Wire-compatible dialects (near-zero new container code)
mariadb,timescaledb, andyugabytedbare all wire-compatible with an existing base dialect, so they reuse testcontainers'MySqlContainer/PostgresContainerclasses pointed at a different image rather than needing new container-class wiring —mariadb:11,timescale/timescaledb:latest-pg16, andyugabytedb/yugabyte:latestrespectively.yugabytedbneeded one adjustment though:PostgresContainer's built-in readiness check execspsql, which the yugabyte image doesn't ship (only its ownysqlsh). Used a genericDockerContainerinstead, started viayugabyted start --background=falseand waiting on yugabyted's own final startup log line ("Data placement constraint successfully verified").monetdb (no native testcontainers module)
Uses a generic
DockerContainerwith the documentedMDB_*environment variables and a log-based wait strategy. Publishes an amd64-only image — confirmed it actually runs under Rosetta/QEMU emulation on Apple Silicon (unlike CrateDB, which fails outright on its x86-64-v3 CPU instruction-set requirement even under emulation).mongodb (two real bugs found writing this one)
MongoDB is schemaless, and Superset talks to it via
pymongosql, a SQL-to-MongoDB translation layer requiring a?mode=supersetquery param. Documents get inserted via the native pymongo driver rather than SQL INSERT, matching how Superset actually encounters MongoDB in practice and avoiding any assumption about pymongosql's own INSERT/DDL support.Two bugs surfaced empirically while wiring this up:
MongoDbContainer.get_connection_url()has no database path segment or query string at all, so naively appending"&mode=superset"glued directly onto the port number instead of starting a query string — fixed by building the full URL manually. And the root userMongoDbContainercreates lives in theadmindatabase, so connecting with a different default database in the URL path fails authentication outright unlessauthSource=adminis specified explicitly.Confirmed
pymongosqlactually supportsOFFSET(it maps to MongoDB's nativeskip), unlike Elasticsearch's SQL layer in the base PR, which has noOFFSETsupport at all — so this one keeps the fullLIMIT/OFFSETpagination test rather than theLIMIT-only version.New extras added
monetdb(sqlalchemy-monetdb,pymonetdb) andmongodb(pymongosql) are genuinely new pyproject.toml extras.mariadb,timescaledb, andyugabytedbare added as thin aliases (apache-superset[mysql]/apache-superset[postgres]) since they need no new packages —mysqlclient/psycopg2-binaryare already pulled in via the existingmysql/postgresextras.TESTING INSTRUCTIONS
8 passed locally.
mariadbneeds CI (Linux) to verify due to the local mysqlclient issue noted above.ADDITIONAL INFORMATION