bxsx opened a new pull request, #45983: URL: https://github.com/apache/superset/pull/45983
### SUMMARY With clickhouse-connect >= 1.10.1, every ClickHouse view is listed twice in the table selector (New dataset, SQL Lab): once as a table and once as a view. Superset lists a schema as `get_table_names()` plus `get_view_names()`. The clickhouse-connect dialect's `get_table_names` runs `SHOW TABLES`, which includes views. Its `get_view_names` returned an empty list until 1.10.1, which made it return the views too ([ClickHouse/clickhouse-connect#1091](https://github.com/ClickHouse/clickhouse-connect/pull/1091)). Per its changelog, `get_table_names()` keeps including views for backward compatibility. The duplicate entries share a value, and the select's virtual list keys rows by value. While scrolling it renders stale rows: views repeated more than twice, out of order, and two rows highlighted at once. This adds `ClickHouseConnectEngineSpec.get_table_names`, which subtracts the view names. `PrestoEngineSpec` and `DatabricksEngineSpec` already do this for dialects whose `get_table_names` includes views. Materialized views are not affected: the dialect's `get_view_names` returns only `View` and `WindowView` engines, so a materialized view is still listed once, as a table. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Before: views are listed with the table icon, repeated and out of order while scrolling. After: each view appears once, with the view icon. ### TESTING INSTRUCTIONS - `pytest tests/unit_tests/db_engine_specs/test_clickhouse.py`. The new `test_connect_get_table_names_excludes_views` fails without the change: the result includes `v1`. - Manually, against ClickHouse with clickhouse-connect >= 1.10.1: ```sql CREATE DATABASE demo; CREATE TABLE demo.events (id UInt32) ENGINE = MergeTree ORDER BY id; CREATE VIEW demo.events_v AS SELECT id FROM demo.events; CREATE MATERIALIZED VIEW demo.events_mv ENGINE = MergeTree ORDER BY id AS SELECT id FROM demo.events; ``` Then: - add the database (`clickhousedb://…/demo`); - open Datasets → + Dataset and pick the `demo` schema; - `events_v` is listed once, as a view; `events`, `events_mv` and the materialized view's inner `.inner_id.…` table are listed as tables, as before. Before the change, `GET /api/v1/database/<id>/tables/?q=(schema_name:demo)` returns `events_v` with both `"type": "table"` and `"type": "view"`. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] 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 -- 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]
