From 67601e64945535859a5a1e7fccf1f429afd99cdf Mon Sep 17 00:00:00 2001 From: kris tan <145995558+KrisWuli006@users.noreply.github.com> Date: Mon, 14 Sep 2026 11:35:48 +0800 Subject: [PATCH] fix(datasource): filter Hive partition metadata from table fields Ignore blank names and DESCRIBE metadata headers. Retain partition columns once in their original order, preserve valid hash-prefixed column names, and keep support for extra driver columns. Refs dataease/SQLBot#1250. --- backend/apps/db/db.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index 0b88f15a..b8ca4dba 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -598,7 +598,19 @@ def get_fields(ds: CoreDatasource, table_name: str = None): with get_driver_pool(ds).connection() as conn, conn.cursor() as cursor: cursor.execute(sql) res = cursor.fetchall() - res_list = [ColumnSchema(*item[:3]) for item in res] + res_list = [] + seen_fields = set() + for item in res: + field_name = item[0] + if not field_name or not field_name.strip(): + continue + # DESCRIBE includes section headings and repeats partition columns. + if field_name.lstrip().startswith('#') and (item[1] or '').strip() in ('', 'data_type'): + continue + if field_name in seen_fields: + continue + seen_fields.add(field_name) + res_list.append(ColumnSchema(*item[:3])) return res_list