"Sync columns from source" fails on ClickHouse tables with ALIAS, MATERIALIZED or DEFAULT columns
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
Research direction
Start in convert_inspector_columns, which copies every key from the ClickHouse dialect's get_columns output, and trace how /datasource/external_metadata_by_name/ passes that list to json_response. Reproduce by creating a MergeTree table with an ALIAS column and calling that endpoint, which should return the 500 described. Done when the endpoint returns the column list for such a table, with the SQLAlchemy clause values converted to strings and column_name, type and is_dttm still present.
Written by the indexing model from the issue text.
Description
Bug description
In the dataset editor, Sync columns from source fails on any ClickHouse table with an ALIAS, MATERIALIZED, DEFAULT or TTL column. Instead of syncing, it shows Unserializable object price * qty of type <class 'sqlalchemy.sql.elements.TextClause'>, so new or changed columns on those tables can't be picked up from the UI.
Cause. Since clickhouse-connect 1.1.0, the dialect's get_columns returns those expressions as SQLAlchemy text() clauses (clickhouse_alias, clickhouse_materialized, server_default, clickhouse_ttl). convert_inspector_columns copies every inspector key, and /datasource/external_metadata_by_name/ returns the list through json_response, which can't encode a clause.
How to reproduce (ClickHouse 25.3, clickhouse-connect 1.11.0, the latest release)
CREATE TABLE t (ts DateTime, price Float64, qty UInt32, total Float64 ALIAS price * qty) ENGINE = MergeTree ORDER BY ts;
- Add
tas a dataset (this works). - Edit the dataset, open the Columns tab and click Sync columns from source.
- An error toast appears, and the endpoint returns
500 {"error": "Unserializable object price * qty of type <class 'sqlalchemy.sql.elements.TextClause'>"}.
day Date MATERIALIZED toDate(ts), note String DEFAULT 'x' and note String TTL ts + INTERVAL 30 DAY fail the same way. Tables without such columns sync fine.
Proposal. In convert_inspector_columns, turn SQLAlchemy ClauseElement values into their SQL string ("clickhouse_alias": "price * qty"). The editor only reads column_name, type and is_dttm from the result, so nothing else changes. PR to follow.
Screenshots/recordings
On 7.0.0rc2, after adding a column with ALTER TABLE t ADD COLUMN discount Float64 ALIAS price * 0.1: the sync shows the error toast and the new column is not added (Columns 4).
Superset version
master / latest-dev
Python version
3.11
Node version
Not applicable
Browser
Not applicable
Additional context
- Versions: the latest clickhouse-connect and every release since 1.1.0. The documented Docker install (
echo "clickhouse-connect>=0.13.0" >> ./docker/requirements-local.txt) pulls the latest, 1.11.0, on 6.1 and 7.0 alike. Only 6.1'sapache-superset[clickhouse]extra (<1.0) avoids it; since #40944, 7.0's extra requires>=1.7.2and CI runs 1.7.2, so on 7.0 every route hits it. - Workaround:
PUT /api/v1/dataset/<id>/refreshrefreshes the columns from the source and works. - cc @joe-clickhouse, @hughhhh (#24248), @rusackas (#40944)
Checklist
- I have searched Superset docs and Slack and didn't find a solution to my problem.
- I have searched the GitHub issue tracker and didn't find a similar bug report.
- I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
- Dominant language
- Python
- Stars
- 75.4k
- Forks
- 18.6k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 592
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/superset
-
[Bug] Table chart applies Time grain to only the first temporal column (regression from 4.0.2)Possibly taken @schizophrenicmaniac claimed this 1 day ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/superset#45964 · 1 comment ·
Maintainers usually reply within 1 day
-
Chart and dashboard thumbnails ignore SUPERSET_APP_ROOTPossibly taken @greg-om claimed this 12 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/superset#45638 · 1 comment ·
Maintainers usually reply within 1 day
-
Bar chart: bars on a temporal x-axis shrink to hairlines when the time grain is finer than the data (7.0.0rc2)Possibly taken @Anikesh0001 claimed this 14 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/superset#45474 · 4 comments ·
Maintainers usually reply within 1 day
-
get_time_filter Jinja macro returns 500 when the chart has a custom SQL filterPossibly taken @SEPURI-SAI-KRISHNA claimed this 20 days ago. Open🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/superset#45269 · 2 comments ·
Maintainers usually reply within 1 day
-
flatten post-processing drops index columns when the index has several levelsPossibly taken @AliIbnBotir claimed this 20 days ago. Open#bug 🦾 ai-candidate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/superset#45261 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
bump patch
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#1321 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
QuantConnect/Documentation#2838 ·
Maintainers usually reply within 1 day
-
get_all_subclasses must deduplicate by class identityPossibly taken @Gambit-Checkmate claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 15 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 comment ·