Merge pull request #231 from peacewong/master
Modify the SQL comment standardization problem and exclude the CDH version Jasper package
diff --git a/core/cloudModule/pom.xml b/core/cloudModule/pom.xml
index 1d3425e..d0bfc20 100644
--- a/core/cloudModule/pom.xml
+++ b/core/cloudModule/pom.xml
@@ -332,4 +332,4 @@
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/config/LinkisMybatisConfig.java b/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/config/LinkisMybatisConfig.java
index 0154e4a..d4737f1 100644
--- a/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/config/LinkisMybatisConfig.java
+++ b/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/config/LinkisMybatisConfig.java
@@ -21,6 +21,8 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.ibatis.mapping.DatabaseIdProvider;
+import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
@@ -39,9 +41,9 @@
import java.io.IOException;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+
+import java.util.*;
+
@Configuration
@EnableTransactionManagement(order = 2)
@@ -176,6 +178,8 @@
}
/* Resource[] resources = new PathMatchingResourcePatternResolver().getResources(mapperLocations);
sessionFactoryBean.setMapperLocations(resources);*/
+ // Add mybatis database id provider configuration to support hive postgresql metadata(添加MyBatis配置以支持Hive PG元数据库)
+ sessionFactoryBean.setDatabaseIdProvider(getDatabaseIdProvider());
// Set the location of the mybatis-config.xml configuration file(设置mybatis-config.xml配置文件位置)
sessionFactoryBean.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
@@ -189,6 +193,15 @@
}
}
+ private DatabaseIdProvider getDatabaseIdProvider() {
+ VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider();
+ Properties databaseIdProperties = new Properties();
+ databaseIdProperties.put("MySQL", "mysql");
+ databaseIdProperties.put("PostgreSQL", "postgresql");
+ databaseIdProvider.setProperties(databaseIdProperties);
+ return databaseIdProvider;
+ }
+
@Primary
public PlatformTransactionManager annotationDrivenTransactionManager(@Qualifier("dataSource") DynamicDataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
diff --git a/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/dao/impl/HiveMetaDao.xml b/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/dao/impl/HiveMetaDao.xml
index 06198f7..76fa052 100644
--- a/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/dao/impl/HiveMetaDao.xml
+++ b/metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/hive/dao/impl/HiveMetaDao.xml
@@ -18,120 +18,432 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.webank.wedatasphere.linkis.metadata.hive.dao.HiveMetaDao">
- <select id="getLocationByDbAndTable" resultType="java.lang.String" parameterType="map">
+ <select id="getLocationByDbAndTable" resultType="java.lang.String" parameterType="map" databaseId="mysql">
select LOCATION from SDS where SD_ID in (
- select SD_ID from `TBLS`
- where TBL_NAME = #{tableName,jdbcType=VARCHAR}
- and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
+ select SD_ID from `TBLS`
+ where TBL_NAME = #{tableName,jdbcType=VARCHAR}
+ and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
)
</select>
- <select id="getDbsByUser" resultType="java.lang.String" parameterType="java.lang.String">
+ <select id="getDbsByUser" resultType="java.lang.String" parameterType="java.lang.String" databaseId="mysql">
select NAME from(
- select t2.NAME as NAME
- from DB_PRIVS t1, DBS t2
- where (lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR}
- OR t1.PRINCIPAL_NAME IN (SELECT ROLE FROM(SELECT r.ROLE_NAME AS ROLE, u.PRINCIPAL_NAME AS USER FROM ROLES r LEFT JOIN (SELECT * FROM ROLE_MAP WHERE PRINCIPAL_TYPE = 'USER') u ON r.ROLE_ID = u.ROLE_ID)AS T where T.USER = #{userName,jdbcType=VARCHAR}))
- and lcase(t1.DB_PRIV) in ('select','all') and t1.DB_ID =t2.DB_ID
- union all
- select t3.NAME as NAME
- from TBL_PRIVS t1, TBLS t2 , DBS t3
- where t1.TBL_ID=t2.TBL_ID and lcase(t1.TBL_PRIV) in ('select','all') and (
- lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR} or lcase(t1.PRINCIPAL_NAME) in (SELECT ROLE FROM(SELECT r.ROLE_NAME AS ROLE, u.PRINCIPAL_NAME AS USER FROM ROLES r LEFT JOIN (SELECT * FROM ROLE_MAP WHERE PRINCIPAL_TYPE = 'USER') u ON r.ROLE_ID = u.ROLE_ID)AS T where T.USER = #{userName,jdbcType=VARCHAR}))
- and t2.DB_ID=t3.DB_ID) a
+ select t2.NAME as NAME
+ from DB_PRIVS t1, DBS t2
+ where (lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR}
+ OR t1.PRINCIPAL_NAME IN (SELECT ROLE FROM(SELECT r.ROLE_NAME AS ROLE, u.PRINCIPAL_NAME AS USER FROM ROLES r LEFT JOIN (SELECT * FROM ROLE_MAP WHERE PRINCIPAL_TYPE = 'USER') u ON r.ROLE_ID = u.ROLE_ID)AS T where T.USER = #{userName,jdbcType=VARCHAR}))
+ and lcase(t1.DB_PRIV) in ('select','all') and t1.DB_ID =t2.DB_ID
+ union all
+ select t3.NAME as NAME
+ from TBL_PRIVS t1, TBLS t2 , DBS t3
+ where t1.TBL_ID=t2.TBL_ID and lcase(t1.TBL_PRIV) in ('select','all') and (
+ lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR} or lcase(t1.PRINCIPAL_NAME) in (SELECT ROLE FROM(SELECT r.ROLE_NAME AS ROLE, u.PRINCIPAL_NAME AS USER FROM ROLES r LEFT JOIN (SELECT * FROM ROLE_MAP WHERE PRINCIPAL_TYPE = 'USER') u ON r.ROLE_ID = u.ROLE_ID)AS T where T.USER = #{userName,jdbcType=VARCHAR}))
+ and t2.DB_ID=t3.DB_ID) a
GROUP BY NAME
order by NAME
</select>
- <select id="getTablesByDbNameAndUser" resultType="map" parameterType="map">
+ <select id="getTablesByDbNameAndUser" resultType="map" parameterType="map" databaseId="mysql">
select t2.TBL_NAME as NAME, t2.TBL_TYPE as TYPE, t2.CREATE_TIME as CREATE_TIME, t2.LAST_ACCESS_TIME as LAST_ACCESS_TIME, t2.OWNER as OWNER
from DB_PRIVS t1,TBLS t2, DBS t3
where t1.DB_ID =t3.DB_ID
- and t2.DB_ID=t3.DB_ID
- and lcase(t1.DB_PRIV) in ('select','all')
- and lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR}
- and t3.NAME = #{dbName,jdbcType=VARCHAR}
+ and t2.DB_ID=t3.DB_ID
+ and lcase(t1.DB_PRIV) in ('select','all')
+ and lcase(t1.PRINCIPAL_NAME) = #{userName,jdbcType=VARCHAR}
+ and t3.NAME = #{dbName,jdbcType=VARCHAR}
union
select t2.TBL_NAME as NAME, t2.TBL_TYPE as TYPE, t2.CREATE_TIME as CREATE_TIME, t2.LAST_ACCESS_TIME as LAST_ACCESS_TIME, t2.OWNER as OWNER
from DB_PRIVS t1,TBLS t2, DBS t3
where t1.DB_ID =t3.DB_ID
- and t2.DB_ID=t3.DB_ID
- and lcase(t1.DB_PRIV) in ('select','all')
- and lcase(t1.PRINCIPAL_NAME) in (select ROLE_NAME from ROLES where ROLE_ID in (select ROLE_ID from ROLE_MAP where PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}))
- and t3.NAME = #{dbName,jdbcType=VARCHAR}
+ and t2.DB_ID=t3.DB_ID
+ and lcase(t1.DB_PRIV) in ('select','all')
+ and lcase(t1.PRINCIPAL_NAME) in (select ROLE_NAME from ROLES where ROLE_ID in (select ROLE_ID from ROLE_MAP where PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}))
+ and t3.NAME = #{dbName,jdbcType=VARCHAR}
union
select t2.TBL_NAME as NAME, t2.TBL_TYPE as TYPE, t2.CREATE_TIME as CREATE_TIME, t2.LAST_ACCESS_TIME as LAST_ACCESS_TIME, t2.OWNER as OWNER
from TBL_PRIVS t1, TBLS t2 , DBS t3
where t1.TBL_ID=t2.TBL_ID
- and t2.DB_ID=t3.DB_ID
- and lcase(t1.TBL_PRIV) in ('select','all')
- and t1.PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}
- and t3.NAME = #{dbName,jdbcType=VARCHAR}
+ and t2.DB_ID=t3.DB_ID
+ and lcase(t1.TBL_PRIV) in ('select','all')
+ and t1.PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}
+ and t3.NAME = #{dbName,jdbcType=VARCHAR}
union
select t2.TBL_NAME as NAME, t2.TBL_TYPE as TYPE, t2.CREATE_TIME as CREATE_TIME, t2.LAST_ACCESS_TIME as LAST_ACCESS_TIME, t2.OWNER as OWNER
from TBL_PRIVS t1, TBLS t2 , DBS t3
where t1.TBL_ID=t2.TBL_ID
- and t2.DB_ID=t3.DB_ID
- and lcase(t1.TBL_PRIV) in ('select','all')
- and t1.PRINCIPAL_NAME in (select ROLE_NAME from ROLES where ROLE_ID in (select ROLE_ID from ROLE_MAP where PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}))
- and t3.NAME = #{dbName,jdbcType=VARCHAR}
+ and t2.DB_ID=t3.DB_ID
+ and lcase(t1.TBL_PRIV) in ('select','all')
+ and t1.PRINCIPAL_NAME in (select ROLE_NAME from ROLES where ROLE_ID in (select ROLE_ID from ROLE_MAP where PRINCIPAL_NAME = #{userName,jdbcType=VARCHAR}))
+ and t3.NAME = #{dbName,jdbcType=VARCHAR}
order by NAME;
</select>
- <select id="getPartitionSize" resultType="java.lang.Long" parameterType="map">
+ <select id="getPartitionSize" resultType="java.lang.Long" parameterType="map" databaseId="mysql">
select PARAM_VALUE from PARTITION_PARAMS
where PARAM_KEY = 'totalSize'
- and PART_ID in (
- select PART_ID from PARTITIONS
- where PART_NAME = #{partitionName,jdbcType=VARCHAR}
- and TBL_ID in(
- select TBL_ID from `TBLS`
- where TBL_NAME = #{tableName,jdbcType=VARCHAR}
- and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
- )
+ and PART_ID in (
+ select PART_ID from PARTITIONS
+ where PART_NAME = #{partitionName,jdbcType=VARCHAR}
+ and TBL_ID in(
+ select TBL_ID from `TBLS`
+ where TBL_NAME = #{tableName,jdbcType=VARCHAR}
+ and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
+ )
);
</select>
- <select id="getPartitions" resultType="java.lang.String" parameterType="map">
+ <select id="getPartitions" resultType="java.lang.String" parameterType="map" databaseId="mysql">
select PART_NAME from PARTITIONS
where TBL_ID in(
- select TBL_ID from `TBLS`
- where TBL_NAME = #{tableName,jdbcType=VARCHAR}
- and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
+ select TBL_ID from `TBLS`
+ where TBL_NAME = #{tableName,jdbcType=VARCHAR}
+ and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
);
</select>
- <select id="getColumns" resultType="map" parameterType="map">
+ <select id="getColumns" resultType="map" parameterType="map" databaseId="mysql">
SELECT COMMENT, COLUMN_NAME, TYPE_NAME FROM COLUMNS_V2
where CD_ID in(
- select CD_ID from SDS where SD_ID in (
- select SD_ID from `TBLS`
- where TBL_NAME = #{tableName,jdbcType=VARCHAR}
- and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
- )
+ select CD_ID from SDS where SD_ID in (
+ select SD_ID from `TBLS`
+ where TBL_NAME = #{tableName,jdbcType=VARCHAR}
+ and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
+ )
) order by INTEGER_IDX asc;
</select>
- <select id="getPartitionKeys" resultType="map" parameterType="map">
+ <select id="getPartitionKeys" resultType="map" parameterType="map" databaseId="mysql">
select PKEY_COMMENT, PKEY_NAME, PKEY_TYPE from PARTITION_KEYS
where TBL_ID in(
- select TBL_ID from `TBLS`
- where TBL_NAME = #{tableName,jdbcType=VARCHAR}
- and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
+ select TBL_ID from `TBLS`
+ where TBL_NAME = #{tableName,jdbcType=VARCHAR}
+ and DB_ID in (select DB_ID from `DBS` where NAME = #{dbName,jdbcType=VARCHAR})
);
</select>
- <select id="getTableComment" resultType="String">
+ <select id="getTableComment" resultType="String" databaseId="mysql">
SELECT
- tp.PARAM_VALUE
+ tp.PARAM_VALUE
FROM
- `DBS` d
- LEFT JOIN `TBLS` t ON d.DB_ID = t.DB_ID
- LEFT JOIN `TABLE_PARAMS` tp ON t.TBL_ID = tp.TBL_ID
+ `DBS` d
+ LEFT JOIN `TBLS` t ON d.DB_ID = t.DB_ID
+ LEFT JOIN `TABLE_PARAMS` tp ON t.TBL_ID = tp.TBL_ID
WHERE
- tp.PARAM_KEY = 'comment'
- AND d.`NAME` = #{DbName}
- AND t.TBL_NAME = #{tableName}
+ tp.PARAM_KEY = 'comment'
+ AND d.`NAME` = #{DbName}
+ AND t.TBL_NAME = #{tableName}
+ </select>
+
+ <select id="getLocationByDbAndTable" resultType="java.lang.String" parameterType="map" databaseId="postgresql">
+ select
+ "LOCATION"
+ from
+ "SDS"
+ where
+ "SD_ID" in (
+ select
+ "SD_ID"
+ from
+ "TBLS"
+ where
+ "TBL_NAME" = #{tableName, jdbcType = VARCHAR}
+ and "DB_ID" in (
+ select
+ "DB_ID"
+ from
+ "DBS"
+ where
+ "NAME" = #{dbName, jdbcType = VARCHAR}) )
+ </select>
+
+ <select id="getDbsByUser" resultType="java.lang.String" parameterType="java.lang.String" databaseId="postgresql">
+ select
+ "NAME"
+ from
+ (
+ select
+ t2."NAME" as "NAME"
+ from
+ "DB_PRIVS" t1,
+ "DBS" t2
+ where
+ (lower(t1."PRINCIPAL_NAME") = #{userName, jdbcType = VARCHAR}
+ or t1."PRINCIPAL_NAME" in (
+ select
+ "ROLE"
+ from
+ (
+ select
+ r."ROLE_NAME" as "ROLE",
+ u."PRINCIPAL_NAME" as "USER"
+ from
+ "ROLES" r
+ left join (
+ select
+ *
+ from
+ "ROLE_MAP"
+ where
+ "PRINCIPAL_TYPE" = 'USER') u on
+ r."ROLE_ID" = u."ROLE_ID") as T
+ where
+ T."USER" = #{userName, jdbcType = VARCHAR}))
+ and lower(t1."DB_PRIV") in ('select', 'all')
+ and t1."DB_ID" = t2."DB_ID"
+ union all
+ select
+ t3."NAME" as "NAME"
+ from
+ "TBL_PRIVS" t1,
+ "TBLS" t2 ,
+ "DBS" t3
+ where
+ t1."TBL_ID" = t2."TBL_ID"
+ and lower(t1."TBL_PRIV") in ('select', 'all')
+ and ( lower(t1."PRINCIPAL_NAME") = #{userName, jdbcType = VARCHAR}
+ or lower(t1."PRINCIPAL_NAME") in (
+ select
+ "ROLE"
+ from
+ (
+ select
+ r."ROLE_NAME" as "ROLE",
+ u."PRINCIPAL_NAME" as "USER"
+ from
+ "ROLES" r
+ left join (
+ select
+ *
+ from
+ "ROLE_MAP"
+ where
+ "PRINCIPAL_TYPE" = 'USER') u on
+ r."ROLE_ID" = u."ROLE_ID")as T
+ where
+ T."USER" = #{userName, jdbcType = VARCHAR}))
+ and t2."DB_ID" = t3."DB_ID") a
+ group by
+ "NAME"
+ order by
+ "NAME"
+ </select>
+
+ <select id="getTablesByDbNameAndUser" resultType="map" parameterType="map" databaseId="postgresql">
+ select
+ t2."TBL_NAME" as "NAME",
+ t2."TBL_TYPE" as "TYPE",
+ cast(t2."CREATE_TIME" as int4) as "CREATE_TIME",
+ cast(t2."LAST_ACCESS_TIME" as int4) as "LAST_ACCESS_TIME",
+ t2."OWNER" as "OWNER"
+ from
+ "DB_PRIVS" t1,
+ "TBLS" t2,
+ "DBS" t3
+ where
+ t1."DB_ID" = t3."DB_ID"
+ and t2."DB_ID" = t3."DB_ID"
+ and lower(t1."DB_PRIV") in ('select', 'all')
+ and lower(t1."PRINCIPAL_NAME") = #{userName, jdbcType = VARCHAR}
+ and t3."NAME" = #{dbName, jdbcType = VARCHAR}
+ union
+ select
+ t2."TBL_NAME" as "NAME",
+ t2."TBL_TYPE" as "TYPE",
+ cast(t2."CREATE_TIME" as int4) as "CREATE_TIME",
+ cast(t2."LAST_ACCESS_TIME" as int4) as "LAST_ACCESS_TIME",
+ t2."OWNER" as "OWNER"
+ from
+ "DB_PRIVS" t1,
+ "TBLS" t2,
+ "DBS" t3
+ where
+ t1."DB_ID" = t3."DB_ID"
+ and t2."DB_ID" = t3."DB_ID"
+ and lower(t1."DB_PRIV") in ('select', 'all')
+ and lower(t1."PRINCIPAL_NAME") in (
+ select
+ "ROLE_NAME"
+ from
+ "ROLES"
+ where
+ "ROLE_ID" in (
+ select
+ "ROLE_ID"
+ from
+ "ROLE_MAP"
+ where
+ "PRINCIPAL_NAME" = #{userName, jdbcType = VARCHAR}))
+ and t3."NAME" = #{dbName, jdbcType = VARCHAR}
+ union
+ select
+ t2."TBL_NAME" as "NAME",
+ t2."TBL_TYPE" as "TYPE",
+ cast(t2."CREATE_TIME" as int4) as "CREATE_TIME",
+ cast(t2."LAST_ACCESS_TIME" as int4) as "LAST_ACCESS_TIME",
+ t2."OWNER" as "OWNER"
+ from
+ "TBL_PRIVS" t1,
+ "TBLS" t2,
+ "DBS" t3
+ where
+ t1."TBL_ID" = t2."TBL_ID"
+ and t2."DB_ID" = t3."DB_ID"
+ and lower(t1."TBL_PRIV") in ('select', 'all')
+ and t1."PRINCIPAL_NAME" = #{userName, jdbcType = VARCHAR}
+ and t3."NAME" = #{dbName, jdbcType = VARCHAR}
+ union
+ select
+ t2."TBL_NAME" as "NAME",
+ t2."TBL_TYPE" as "TYPE",
+ cast(t2."CREATE_TIME" as int4) as "CREATE_TIME",
+ cast(t2."LAST_ACCESS_TIME" as int4) as "LAST_ACCESS_TIME",
+ t2."OWNER" as "OWNER"
+ from
+ "TBL_PRIVS" t1,
+ "TBLS" t2,
+ "DBS" t3
+ where
+ t1."TBL_ID" = t2."TBL_ID"
+ and t2."DB_ID" = t3."DB_ID"
+ and lower(t1."TBL_PRIV") in ('select', 'all')
+ and t1."PRINCIPAL_NAME" in (
+ select
+ "ROLE_NAME"
+ from
+ "ROLES"
+ where
+ "ROLE_ID" in (
+ select
+ "ROLE_ID"
+ from
+ "ROLE_MAP"
+ where
+ "PRINCIPAL_NAME" = #{userName, jdbcType = VARCHAR}))
+ and t3."NAME" = #{dbName, jdbcType = VARCHAR}
+ order by
+ "NAME";
+ </select>
+
+ <select id="getPartitionSize" resultType="java.lang.Long" parameterType="map" databaseId="postgresql">
+ select
+ "PARAM_VALUE"
+ from
+ "PARTITION_PARAMS"
+ where
+ "PARAM_KEY" = 'totalSize'
+ and "PART_ID" in (
+ select
+ "PART_ID"
+ from
+ "PARTITIONS"
+ where
+ "PART_NAME" = #{partitionName, jdbcType = VARCHAR}
+ and "TBL_ID" in(
+ select
+ "TBL_ID"
+ from
+ "TBLS"
+ where
+ "TBL_NAME" = #{tableName, jdbcType = VARCHAR}
+ and "DB_ID" in (
+ select
+ "DB_ID"
+ from
+ "DBS"
+ where
+ "NAME" = #{dbName, jdbcType = VARCHAR}) ) );
+ </select>
+
+ <select id="getPartitions" resultType="java.lang.String" parameterType="map" databaseId="postgresql">
+ select
+ "PART_NAME"
+ from
+ "PARTITIONS"
+ where
+ "TBL_ID" in(
+ select
+ "TBL_ID"
+ from
+ "TBLS"
+ where
+ "TBL_NAME" = #{tableName, jdbcType = VARCHAR}
+ and "DB_ID" in (
+ select
+ "DB_ID"
+ from
+ "DBS"
+ where
+ "NAME" = #{dbName, jdbcType = VARCHAR}) );
+ </select>
+
+ <select id="getColumns" resultType="map" parameterType="map" databaseId="postgresql">
+ select
+ "COMMENT",
+ "COLUMN_NAME",
+ "TYPE_NAME"
+ from
+ "COLUMNS_V2"
+ where
+ "CD_ID" in(
+ select
+ "CD_ID"
+ from
+ "SDS"
+ where
+ "SD_ID" in (
+ select
+ "SD_ID"
+ from
+ "TBLS"
+ where
+ "TBL_NAME" = #{tableName, jdbcType = VARCHAR}
+ and "DB_ID" in (
+ select
+ "DB_ID"
+ from
+ "DBS"
+ where
+ "NAME" = #{dbName, jdbcType = VARCHAR}) ) )
+ order by "INTEGER_IDX" asc;
+ </select>
+
+ <select id="getPartitionKeys" resultType="map" parameterType="map" databaseId="postgresql">
+ select
+ "PKEY_COMMENT",
+ "PKEY_NAME",
+ "PKEY_TYPE"
+ from
+ "PARTITION_KEYS"
+ where
+ "TBL_ID" in(
+ select
+ "TBL_ID"
+ from
+ "TBLS"
+ where
+ "TBL_NAME" = #{tableName, jdbcType = VARCHAR}
+ and "DB_ID" in (
+ select
+ "DB_ID"
+ from
+ "DBS"
+ where
+ "NAME" = #{dbName, jdbcType = VARCHAR}) );
+ </select>
+
+ <select id="getTableComment" resultType="String" databaseId="postgresql">
+ select
+ tp."PARAM_VALUE"
+ from
+ "DBS" d
+ left join "TBLS" t on
+ d."DB_ID" = t."DB_ID"
+ left join "TABLE_PARAMS" tp on
+ t."TBL_ID" = tp."TBL_ID"
+ where
+ tp."PARAM_KEY" = 'comment'
+ and d."NAME" = #{DbName}
+ and t."TBL_NAME" = #{tableName}
</select>
</mapper>