@@ -33,7 +33,7 @@ def get_version_sql(ds: CoreDatasource, conf: DatasourceConf):
3333
3434
3535def get_table_sql (ds : CoreDatasource , conf : DatasourceConf , db_version : str = '' ):
36- if ds .type == "mysql" or ds . type == "doris" :
36+ if ds .type == "mysql" :
3737 return """
3838 SELECT
3939 TABLE_NAME,
@@ -128,8 +128,18 @@ def get_table_sql(ds: CoreDatasource, conf: DatasourceConf, db_version: str = ''
128128 pg_class
129129 WHERE
130130 relkind in ('r','p', 'f')
131- AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = :param )
131+ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = %s )
132132 """ , conf .dbSchema
133+ elif ds .type == "doris" :
134+ return """
135+ SELECT
136+ TABLE_NAME,
137+ TABLE_COMMENT
138+ FROM
139+ information_schema.TABLES
140+ WHERE
141+ TABLE_SCHEMA = %s
142+ """ , conf .database
133143
134144
135145def get_field_sql (ds : CoreDatasource , conf : DatasourceConf , table_name : str = None ):
@@ -164,7 +174,7 @@ def get_field_sql(ds: CoreDatasource, conf: DatasourceConf, table_name: str = No
164174 """
165175 sql2 = " AND C.TABLE_NAME = :param2" if table_name is not None and table_name != "" else ""
166176 return sql1 + sql2 , conf .dbSchema , table_name
167- elif ds .type == "pg" or ds .type == "excel" or ds . type == "redshift" :
177+ elif ds .type == "pg" or ds .type == "excel" :
168178 sql1 = """
169179 SELECT a.attname AS COLUMN_NAME,
170180 pg_catalog.format_type(a.atttypid, a.atttypmod) AS DATA_TYPE,
@@ -180,6 +190,22 @@ def get_field_sql(ds: CoreDatasource, conf: DatasourceConf, table_name: str = No
180190 """
181191 sql2 = " AND c.relname = :param2" if table_name is not None and table_name != "" else ""
182192 return sql1 + sql2 , conf .dbSchema , table_name
193+ elif ds .type == "redshift" :
194+ sql1 = """
195+ SELECT a.attname AS COLUMN_NAME,
196+ pg_catalog.format_type(a.atttypid, a.atttypmod) AS DATA_TYPE,
197+ col_description(c.oid, a.attnum) AS COLUMN_COMMENT
198+ FROM pg_catalog.pg_attribute a
199+ JOIN
200+ pg_catalog.pg_class c ON a.attrelid = c.oid
201+ JOIN
202+ pg_catalog.pg_namespace n ON n.oid = c.relnamespace
203+ WHERE n.nspname = %s
204+ AND a.attnum > 0
205+ AND NOT a.attisdropped \
206+ """
207+ sql2 = " AND c.relname = %s" if table_name is not None and table_name != "" else ""
208+ return sql1 + sql2 , conf .dbSchema , table_name
183209 elif ds .type == "oracle" :
184210 sql1 = """
185211 SELECT
@@ -234,3 +260,16 @@ def get_field_sql(ds: CoreDatasource, conf: DatasourceConf, table_name: str = No
234260 """
235261 sql2 = " AND c.TABLE_NAME = :param2" if table_name is not None and table_name != "" else ""
236262 return sql1 + sql2 , conf .dbSchema , table_name
263+ elif ds .type == "doris" :
264+ sql1 = """
265+ SELECT
266+ COLUMN_NAME,
267+ DATA_TYPE,
268+ COLUMN_COMMENT
269+ FROM
270+ INFORMATION_SCHEMA.COLUMNS
271+ WHERE
272+ TABLE_SCHEMA = %s
273+ """
274+ sql2 = " AND TABLE_NAME = %s" if table_name is not None and table_name != "" else ""
275+ return sql1 + sql2 , conf .database , table_name
0 commit comments