From 99731850f8eb65ac5c344159f008c28935647e74 Mon Sep 17 00:00:00 2001 From: Dmitry Dementev Date: Wed, 11 Feb 2026 00:12:04 +0300 Subject: [PATCH] =?UTF-8?q?fix(superset):=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=D0=B0=D1=81=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Добавлен clickhouse-sqlalchemy в Dockerfile для поддержки диалекта - Изменен URI с clickhousedb:// на clickhouse+connect:// - Убран вызов fetch_metadata() в init_superset.py (вызывал ошибку диалекта) - Датасеты создаются без предварительного fetch_metadata Тестирование: - Чистый запуск: ✅ - Перезапуск: ✅ - API: ✅ --- Dockerfile.superset | 2 +- superset/init_superset.py | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Dockerfile.superset b/Dockerfile.superset index ada0f89..e8608b3 100644 --- a/Dockerfile.superset +++ b/Dockerfile.superset @@ -8,4 +8,4 @@ RUN apt-get update && \ USER superset -RUN pip install clickhouse-connect==0.8.* psycopg2-binary==2.9.* +RUN pip install clickhouse-connect==0.8.* clickhouse-sqlalchemy==0.3.* psycopg2-binary==2.9.* diff --git a/superset/init_superset.py b/superset/init_superset.py index d4eb1c3..e3946cc 100644 --- a/superset/init_superset.py +++ b/superset/init_superset.py @@ -54,7 +54,7 @@ def build_clickhouse_uri() -> str: host = CLICKHOUSE_HOST port = CLICKHOUSE_PORT database = quote_plus(CLICKHOUSE_DATABASE) - return f"clickhousedb://{user}:{password}@{host}:{port}/{database}" + return f"clickhouse+connect://{user}:{password}@{host}:{port}/{database}" def run_superset_cli(args): @@ -139,6 +139,7 @@ def import_datasets(): # Создаем Python скрипт для выполнения внутри superset shell script_lines = [ + "import clickhouse_connect # Регистрирует диалект clickhouse+connect", "from superset.extensions import db", "from superset.models.core import Database", "from superset.connectors.sqla.models import SqlaTable", @@ -169,18 +170,7 @@ def import_datasets(): ").first()" ), "if existing:", - " try:", - " if not existing.columns:", - " existing.fetch_metadata()", - " db.session.commit()", - f" print('Refreshed dataset metadata: {table_name}')", - " refreshed += 1", - " else:", - f" print('Dataset {table_name} already exists')", - " except Exception as e:", - f" print(f'ERROR: failed to refresh {table_name}: {{e}}')", - " db.session.rollback()", - " errors += 1", + f" print('Dataset {table_name} already exists')", "else:", " try:", ( @@ -193,10 +183,8 @@ def import_datasets(): ")" ), " db.session.add(dataset)", - " db.session.flush()", - " dataset.fetch_metadata()", " db.session.commit()", - f" print('Created dataset: {table_name}')", + f" print('Created dataset: {table_name} (metadata will be fetched on first use)')", " imported += 1", " except Exception as e:", f" print(f'ERROR: failed to create {table_name}: {{e}}')",