hantmac opened a new pull request, #41513:
URL: https://github.com/apache/superset/pull/41513
### SUMMARY
Connecting to Databend through the dynamic form (individual parameters such
as host/port/username/password) fails with:
> Engine spec "InvalidEngine" does not support being configured via
individual parameters.
Connecting via a full SQLAlchemy URI / DSN works fine.
#### Root cause
`superset/db_engine_specs/databend.py` defined two engine specs that both
use `engine = "databend"`:
- `DatabendEngineSpec` (legacy) — extends `BaseEngineSpec`, has **no**
`parameters_schema` / `build_sqlalchemy_uri`.
- `DatabendConnectEngineSpec` — extends `BasicParametersMixin`, **has**
`parameters_schema`.
When configuring via parameters, DatabaseParametersSchemaMixin calls
get_engine_spec("databend", "databend"). supports_backend() returns
True ignoring the driver whenever a spec declares no drivers
(base.py). Since neither Databend spec declares drivers,
get_engine_spec resolves to the first-defined spec — the legacy one,
which has no parameters_schema, triggering the InvalidEngine error in
superset/databases/schemas.py.
DSN connections are unaffected because they don't hit the parameter
validation branch.
Unlike ClickHouse (clickhouse vs clickhousedb) or Databricks
(pyhive/pyodbc/databricks-connector), Databend has a single connector
(databend-sqlalchemy, driver name databend), so the two specs can't be
disambiguated by engine name or drivers. They are redundant and conflict.
Fix
Merge the two specs into a single full-featured `DatabendEngineSpec`
(extends `BasicParametersMixin`, retaining the legacy DBAPI exception
mapping and `get_function_names`), and keep `DatabendConnectEngineSpec` as
a backwards-compatible alias.
BEFORE/AFTER
Before: configuring Databend via the dynamic parameters form returns
HTTP 422 with the InvalidEngine error.
After: the dynamic parameters form resolves to a spec with
parameters_schema/build_sqlalchemy_uri and the connection succeeds.
TESTING INSTRUCTIONS
- pytest tests/unit_tests/db_engine_specs/test_databend.py
- Manual: add a Databend database via the UI using individual parameters
(host/port/username/password) and confirm the connection test passes.
ADDITIONAL INFORMATION
- Has associated issue
- Required feature flags: n/a
- Changes UI: no (backend-only)
- [ ]Includes DB Migration
- Introduces new feature or API
- Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]