Fix(ChatData):ClickHouse connection testing problem. (#784)

1. group_concat() not supported in clickhouse, use
arrayStringConcat+groupArray instead
2. escaped quotes
This commit is contained in:
Aries-ckt 2023-11-08 13:43:45 +08:00 committed by GitHub
commit 2fe8ca451e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,3 +106,13 @@ class ClickhouseConnect(RDBMSDatabase):
return [
(table_comment[0], table_comment[1]) for table_comment in table_comments
]
def table_simple_info(self):
# group_concat() not supported in clickhouse, use arrayStringConcat+groupArray instead; and quotes need to be escaped
_sql = f"""
select concat(TABLE_NAME, \'(\' , arrayStringConcat(groupArray(column_name),\'-\'), \')\') as schema_info
from information_schema.COLUMNS where table_schema=\'{self.get_current_db_name()}\' group by TABLE_NAME; """
cursor = self.session.execute(text(_sql))
results = cursor.fetchall()
return results