"Sync columns from source" fails on ClickHouse tables with ALIAS, MATERIALIZED or DEFAULT columns

Open Beginner friendly
#45,960 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@bmuraykhi is already working on this.

Since Nov 2, 2026.

  • #45961 by @bmuraykhi — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, databases

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 🦾 ai-candidate
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;
  1. Add t as a dataset (this works).
  2. Edit the dataset, open the Columns tab and click Sync columns from source.
  3. 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).

Image
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's apache-superset[clickhouse] extra (<1.0) avoids it; since #40944, 7.0's extra requires >=1.7.2 and CI runs 1.7.2, so on 7.0 every route hits it.
  • Workaround: PUT /api/v1/dataset/<id>/refresh refreshes 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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/superset

All issues in apache/superset

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.