forked from github/dataease
fix(数据源): 展示表备注信息
This commit is contained in:
parent
e86ba79b2a
commit
e79d696615
@ -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:
|
||||
|
@ -338,6 +338,7 @@ export default {
|
||||
extract: '抽取模式',
|
||||
all_compute_mode: '直连、抽取模式',
|
||||
extra_params: '额外的JDBC连接字符串',
|
||||
jdbcUrl: 'JDBC 连接',
|
||||
please_input_dataPath: '请输入 JsonPath 数据路径',
|
||||
show_api_data: '查看API数据结构',
|
||||
warning: '包含无效数据表',
|
||||
|
@ -1122,14 +1122,14 @@ const getMenuList = (val: boolean) => {
|
||||
</el-col>
|
||||
</el-row>
|
||||
<template v-if="!['Excel', 'API'].includes(nodeInfo.type)">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType === 'hostName'">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.host')">{{
|
||||
nodeInfo.configuration.host
|
||||
}}</BaseInfoItem>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType === 'hostName'">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.port')">{{
|
||||
nodeInfo.configuration.port
|
||||
@ -1141,7 +1141,7 @@ const getMenuList = (val: boolean) => {
|
||||
}}</BaseInfoItem>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType === 'hostName'">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.user_name')">{{
|
||||
nodeInfo.configuration.username
|
||||
@ -1153,14 +1153,14 @@ const getMenuList = (val: boolean) => {
|
||||
}}</BaseInfoItem>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'hostName'">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType === 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.jdbcUrl')">{{
|
||||
nodeInfo.configuration.jdbcUrl
|
||||
}}</BaseInfoItem>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType !== 'hostName'">
|
||||
<el-row :gutter="24" v-show="nodeInfo.configuration.urlType === 'jdbcUrl'">
|
||||
<el-col :span="12">
|
||||
<BaseInfoItem :label="t('datasource.user_name')">{{
|
||||
nodeInfo.configuration.username
|
||||
|
Loading…
Reference in New Issue
Block a user