From e79d696615c9a17fcde4aa602d43ab199a6b18fe Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 21 May 2024 12:16:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E6=BA=90):=20=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E8=A1=A8=E5=A4=87=E6=B3=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/provider/CalciteProvider.java | 62 +++++++++++++++---- core/core-frontend/src/locales/zh-CN.ts | 1 + .../visualized/data/datasource/index.vue | 10 +-- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java index 78e2fa9625..0964609d9e 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java @@ -117,7 +117,11 @@ public class CalciteProvider { tableDesc.setDatasourceId(datasourceRequest.getDatasource().getId()); tableDesc.setType("db"); tableDesc.setTableName(resultSet.getString(1)); - tableDesc.setName(resultSet.getString(2)); + if(resultSet.getMetaData().getColumnCount() > 1){ + tableDesc.setName(resultSet.getString(2)); + }else { + tableDesc.setName(resultSet.getString(1)); + } return tableDesc; } @@ -778,38 +782,72 @@ public class CalciteProvider { if (StringUtils.isEmpty(configuration.getSchema())) { DEException.throwException(Translator.get("i18n_schema_is_empty")); } - tableSqls.add("select table_name, owner, comments from all_tab_comments where owner='" + configuration.getSchema() + "' AND table_type = 'TABLE'"); - tableSqls.add("select table_name, owner, comments from all_tab_comments where owner='" + configuration.getSchema() + "' AND table_type = 'VIEW'"); + tableSqls.add("select table_name, comments, owner from all_tab_comments where owner='" + configuration.getSchema() + "' AND table_type = 'TABLE'"); + tableSqls.add("select table_name, comments, owner from all_tab_comments where owner='" + configuration.getSchema() + "' AND table_type = 'VIEW'"); break; case db2: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Db2.class); if (StringUtils.isEmpty(configuration.getSchema())) { DEException.throwException(Translator.get("i18n_schema_is_empty")); } - tableSqls.add("select TABNAME from syscat.tables WHERE TABSCHEMA ='DE_SCHEMA' AND \"TYPE\" = 'T'".replace("DE_SCHEMA", configuration.getSchema())); + tableSqls.add("select TABNAME, REMARKS from syscat.tables WHERE TABSCHEMA ='DE_SCHEMA' AND \"TYPE\" = 'T'".replace("DE_SCHEMA", configuration.getSchema())); break; case sqlServer: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Sqlserver.class); if (StringUtils.isEmpty(configuration.getSchema())) { DEException.throwException(Translator.get("i18n_schema_is_empty")); } - tableSqls.add("SELECT TABLE_NAME FROM \"DATABASE\".INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'DS_SCHEMA' ;" - .replace("DATABASE", configuration.getDataBase()) - .replace("DS_SCHEMA", configuration.getSchema())); - tableSqls.add("SELECT TABLE_NAME FROM \"DATABASE\".INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'DS_SCHEMA' ;" - .replace("DATABASE", configuration.getDataBase()) + tableSqls.add("SELECT \n" + + " t.name AS TableName, \n" + + " ep.value AS TableDescription \n" + + "FROM \n" + + " sys.tables t \n" + + "LEFT OUTER JOIN sys.schemas sc ON sc.schema_id =t.schema_id \n" + + "LEFT OUTER JOIN \n" + + " sys.extended_properties ep ON t.object_id = ep.major_id \n" + + " AND ep.minor_id = 0 \n" + + " AND ep.class = 1 \n" + + " AND ep.name = 'MS_Description'\n" + + "where sc.name ='DS_SCHEMA'" .replace("DS_SCHEMA", configuration.getSchema())); + tableSqls.add("SELECT \n" + + " t.name AS TableName, \n" + + " ep.value AS TableDescription \n" + + "FROM \n" + + " sys.views t \n" + + "LEFT OUTER JOIN sys.schemas sc ON sc.schema_id =t.schema_id \n" + + "LEFT OUTER JOIN \n" + + " sys.extended_properties ep ON t.object_id = ep.major_id \n" + + " AND ep.minor_id = 0 \n" + + " AND ep.class = 1 \n" + + " AND ep.name = 'MS_Description'\n" + + "where sc.name ='DS_SCHEMA'" + .replace("DS_SCHEMA", configuration.getSchema())); break; case pg: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Pg.class); if (StringUtils.isEmpty(configuration.getSchema())) { DEException.throwException(Translator.get("i18n_schema_is_empty")); } - tableSqls.add("SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", configuration.getSchema())); + tableSqls.add("SELECT \n" + + " relname AS TableName, \n" + + " obj_description(relfilenode::regclass, 'pg_class') AS TableDescription \n" + + "FROM \n" + + " pg_class \n" + + "WHERE \n" + + " relkind = 'r' \n" + + " AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'SCHEMA') ".replace("SCHEMA", configuration.getSchema())); break; case redshift: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), CK.class); - tableSqls.add("SELECT tablename FROM pg_tables WHERE schemaname='SCHEMA' ;".replace("SCHEMA", configuration.getSchema())); + tableSqls.add("SELECT \n" + + " relname AS TableName, \n" + + " obj_description(relfilenode::regclass, 'pg_class') AS TableDescription \n" + + "FROM \n" + + " pg_class \n" + + "WHERE \n" + + " relkind = 'r' \n" + + " AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'SCHEMA') ".replace("SCHEMA", configuration.getSchema())); break; case ck: configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), CK.class); @@ -822,7 +860,7 @@ public class CalciteProvider { String[] databasePrams = matcher.group(3).split("\\?"); database = databasePrams[0]; } - tableSqls.add("SELECT name FROM system.tables where database='DATABASE';".replace("DATABASE", database)); + tableSqls.add("SELECT name, comment FROM system.tables where database='DATABASE';".replace("DATABASE", database)); break; default: diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 9646d060cb..902b0cf0d1 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -338,6 +338,7 @@ export default { extract: '抽取模式', all_compute_mode: '直连、抽取模式', extra_params: '额外的JDBC连接字符串', + jdbcUrl: 'JDBC 连接', please_input_dataPath: '请输入 JsonPath 数据路径', show_api_data: '查看API数据结构', warning: '包含无效数据表', diff --git a/core/core-frontend/src/views/visualized/data/datasource/index.vue b/core/core-frontend/src/views/visualized/data/datasource/index.vue index 501e0d0cba..c62f2110a1 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/index.vue @@ -1122,14 +1122,14 @@ const getMenuList = (val: boolean) => {