1. group_concat() not supported in clickhouse, use arrayStringConcat+groupArray instead

This commit is contained in:
dulin 2023-11-07 16:56:23 +08:00
parent 6da082bc62
commit f8cb208dc4

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