sadpandajoe opened a new pull request, #46059:
URL: https://github.com/apache/superset/pull/46059
### SUMMARY
PostgreSQL materialized views stopped appearing in the table list (SQL Lab
schema browser, dataset creation picker, `/api/v1/database/<id>/tables/`).
Root cause: #42803 (8014f782d3) bumped SQLAlchemy from 1.4 to 2.0. In
SQLAlchemy 1.4, `PGDialect.get_view_names()` defaulted to `include=("plain",
"materialized")`, so `BaseEngineSpec.get_view_names()` returned Postgres
materialized views alongside plain views. In SQLAlchemy 2.0, `get_view_names()`
returns only plain views (relkind `v`) and materialized views (relkind `m`)
moved to a separate `get_materialized_view_names()`. `PostgresEngineSpec` never
overrode Superset's `get_materialized_view_names()` hook (added for BigQuery in
#34766), so it inherited the base implementation that returns an empty set, and
materialized views fell out of both discovery paths.
This PR overrides `get_materialized_view_names()` in `PostgresEngineSpec` to
call the inspector's dedicated method. The rest of the pipeline already exists:
`Database.get_all_materialized_view_names_in_schema()` caches the result,
`TablesDatabaseCommand` applies the same access check used for views and
returns entries with `type: "materialized_view"`, and `TableSelector` already
renders that type. The override lives on `PostgresEngineSpec` (next to its
`get_table_names()` override) rather than `PostgresBaseEngineSpec`, which is
also used by non-Postgres dialects.
### TESTING INSTRUCTIONS
1. Connect a PostgreSQL database.
2. In it, run `CREATE MATERIALIZED VIEW public.mv_test AS SELECT 1 AS x;`
3. In SQL Lab, select the database and the `public` schema, and refresh the
table list (force refresh).
4. Confirm `mv_test` appears in the list. Before this change it is missing.
5. Go to Datasets → + Dataset, pick the same database and schema, and
confirm `mv_test` is selectable and a dataset can be created from it.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #46054
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
Notes:
- Subclasses of `PostgresEngineSpec` (Aurora, CockroachDB, RisingWave,
Greenplum) inherit the override. CockroachDB's `get_table_names` reads
`information_schema.tables`, so a materialized view there may be listed both as
`table` and `materialized_view`, the same way plain views already appear as
both `table` and `view` today.
- The new unit test mocks the inspector; it covers the engine-spec
delegation, while the `materialized_view` payload construction is covered by
the existing `TablesDatabaseCommand` tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]