mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-13 13:20:22 +00:00
相关代码整理
This commit is contained in:
@@ -6,6 +6,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: dbswitch版本
|
label: dbswitch版本
|
||||||
options:
|
options:
|
||||||
|
- "1.9.8"
|
||||||
- "1.9.7"
|
- "1.9.7"
|
||||||
- "1.9.6"
|
- "1.9.6"
|
||||||
- "1.9.5"
|
- "1.9.5"
|
||||||
@@ -18,7 +19,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: ISSUE类型
|
label: ISSUE类型
|
||||||
options:
|
options:
|
||||||
- "BUG反馈"
|
- "BUG"
|
||||||
- "需求"
|
- "需求"
|
||||||
- "咨询"
|
- "咨询"
|
||||||
validations:
|
validations:
|
||||||
|
@@ -51,6 +51,7 @@
|
|||||||
├── dbswitch-product-sybase // -> sybase方言实现类
|
├── dbswitch-product-sybase // -> sybase方言实现类
|
||||||
├── dbswitch-product-hive // -> hive方言实现类
|
├── dbswitch-product-hive // -> hive方言实现类
|
||||||
├── dbswitch-product-sqlite // -> sqlite方言实现类
|
├── dbswitch-product-sqlite // -> sqlite方言实现类
|
||||||
|
├── dbswitch-product-greenplum // -> greenplum方言实现类
|
||||||
├── dbswitch-product-clickhouse // -> clickhouse方言实现类
|
├── dbswitch-product-clickhouse // -> clickhouse方言实现类
|
||||||
├── dbswitch-product-mongodb // -> mongodb方言实现类
|
├── dbswitch-product-mongodb // -> mongodb方言实现类
|
||||||
├── dbswitch-product-elasticsearch // -> elasticsearch方言实现类
|
├── dbswitch-product-elasticsearch // -> elasticsearch方言实现类
|
||||||
|
@@ -80,7 +80,7 @@ jdbc连接地址:jdbc:gbase://172.17.2.10:5258/gbase
|
|||||||
jdbc驱动名称:com.gbase.jdbc.Driver
|
jdbc驱动名称:com.gbase.jdbc.Driver
|
||||||
```
|
```
|
||||||
|
|
||||||
**翰高HighGo数据库(可按PostgreSQL使用)**
|
**翰高HighGo数据库**
|
||||||
|
|
||||||
```
|
```
|
||||||
jdbc连接地址:jdbc:highgo://172.17.2.10:5866/highgo
|
jdbc连接地址:jdbc:highgo://172.17.2.10:5866/highgo
|
||||||
|
@@ -29,7 +29,7 @@ cd ${DOCKER_DBSWITCH_DIR} \
|
|||||||
# clean project
|
# clean project
|
||||||
cd $PROJECT_ROOT_DIR && sh docker-maven-clean.sh && cd -
|
cd $PROJECT_ROOT_DIR && sh docker-maven-clean.sh && cd -
|
||||||
|
|
||||||
# login and push docker image
|
# push docker image
|
||||||
docker login -u inrgihc
|
docker tag inrgihc/dbswitch:${DBSWITCH_VERSION} registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:${DBSWITCH_VERSION}
|
||||||
docker push inrgihc/dbswitch:${DBSWITCH_VERSION}
|
docker push registry.cn-hangzhou.aliyuncs.com/inrgihc/dbswitch:${DBSWITCH_VERSION}
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
FROM openjdk:8-jre-alpine
|
FROM registry.cn-hangzhou.aliyuncs.com/inrgihc/openjdk:8-jre-alpine
|
||||||
|
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
@@ -10,13 +10,14 @@
|
|||||||
package com.gitee.dbswitch.common.util;
|
package com.gitee.dbswitch.common.util;
|
||||||
|
|
||||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -87,17 +88,17 @@ public final class DatabaseAwareUtils {
|
|||||||
if (driverNameMap.containsKey(driverName)) {
|
if (driverNameMap.containsKey(driverName)) {
|
||||||
ProductTypeEnum productType = driverNameMap.get(driverName);
|
ProductTypeEnum productType = driverNameMap.get(driverName);
|
||||||
if (productType == ProductTypeEnum.POSTGRESQL) {
|
if (productType == ProductTypeEnum.POSTGRESQL) {
|
||||||
// String url = connection.getMetaData().getURL();
|
if (ProductTypeUtils.isGreenplum(connection)) {
|
||||||
// Set<ProductTypeEnum> excludes = Sets.immutableEnumSet(ProductTypeEnum.POSTGRESQL);
|
|
||||||
// ProductTypeEnum pgLikeType = ProductTypeEnum.getProductType(url, excludes);
|
|
||||||
// if (null != pgLikeType) {
|
|
||||||
// return pgLikeType;
|
|
||||||
// }
|
|
||||||
if (DataSourceTypeUtils.isGreenplum(connection)) {
|
|
||||||
return ProductTypeEnum.GREENPLUM;
|
return ProductTypeEnum.GREENPLUM;
|
||||||
}
|
}
|
||||||
|
String url = connection.getMetaData().getURL();
|
||||||
|
Set<ProductTypeEnum> excludes = Sets.immutableEnumSet(ProductTypeEnum.POSTGRESQL, ProductTypeEnum.GREENPLUM);
|
||||||
|
ProductTypeEnum pgLikeType = ProductTypeEnum.getProductType(url, excludes);
|
||||||
|
if (null != pgLikeType) {
|
||||||
|
return pgLikeType;
|
||||||
|
}
|
||||||
} else if (productType == ProductTypeEnum.MYSQL) {
|
} else if (productType == ProductTypeEnum.MYSQL) {
|
||||||
if (isStarRocks(connection)) {
|
if (ProductTypeUtils.isStarRocks(connection)) {
|
||||||
return ProductTypeEnum.STARROCKS;
|
return ProductTypeEnum.STARROCKS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,18 +126,6 @@ public final class DatabaseAwareUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isStarRocks(Connection connection) {
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
|
||||||
// 此查询语句是Starrocks查询be节点是否存活,可以用来判断是否是Starrocks数据源
|
|
||||||
String sql = "SHOW BACKENDS";
|
|
||||||
return statement.execute(sql);
|
|
||||||
} catch (Exception sqlException) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Failed to execute sql :show backends, and guesses it is mysql datasource!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查MySQL数据库表的存储引擎是否为Innodb
|
* 检查MySQL数据库表的存储引擎是否为Innodb
|
||||||
|
@@ -1,18 +1,26 @@
|
|||||||
|
// Copyright tang. All rights reserved.
|
||||||
|
// https://gitee.com/inrgihc/dbswitch
|
||||||
|
//
|
||||||
|
// Use of this source code is governed by a BSD-style license
|
||||||
|
//
|
||||||
|
// Author: tang (inrgihc@126.com)
|
||||||
|
// Date : 2020/1/2
|
||||||
|
// Location: beijing , china
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
package com.gitee.dbswitch.common.util;
|
package com.gitee.dbswitch.common.util;
|
||||||
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class DataSourceTypeUtils {
|
public final class ProductTypeUtils {
|
||||||
|
|
||||||
public static boolean isGreenplum(Connection connection) {
|
public static boolean isGreenplum(Connection connection) {
|
||||||
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement("SELECT version()")) {
|
try (PreparedStatement statement = connection.prepareStatement("SELECT version()")) {
|
||||||
try (ResultSet resultSet = statement.executeQuery()) {
|
try (ResultSet resultSet = statement.executeQuery()) {
|
||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
@@ -31,4 +39,18 @@ public final class DataSourceTypeUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isStarRocks(Connection connection) {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
|
// 此查询语句是Starrocks查询be节点是否存活,可以用来判断是否是Starrocks数据源
|
||||||
|
String sql = "SHOW BACKENDS";
|
||||||
|
return statement.execute(sql);
|
||||||
|
} catch (Exception sqlException) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Failed to execute sql :show backends, and guesses it is mysql datasource!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -13,8 +13,8 @@ import cn.hutool.core.util.ClassLoaderUtil;
|
|||||||
import com.gitee.dbswitch.common.entity.CloseableDataSource;
|
import com.gitee.dbswitch.common.entity.CloseableDataSource;
|
||||||
import com.gitee.dbswitch.common.entity.InvisibleDataSource;
|
import com.gitee.dbswitch.common.entity.InvisibleDataSource;
|
||||||
import com.gitee.dbswitch.common.entity.JarClassLoader;
|
import com.gitee.dbswitch.common.entity.JarClassLoader;
|
||||||
import com.gitee.dbswitch.common.util.DataSourceTypeUtils;
|
|
||||||
import com.gitee.dbswitch.common.util.ExamineUtils;
|
import com.gitee.dbswitch.common.util.ExamineUtils;
|
||||||
|
import com.gitee.dbswitch.common.util.ProductTypeUtils;
|
||||||
import com.gitee.dbswitch.data.domain.WrapCommonDataSource;
|
import com.gitee.dbswitch.data.domain.WrapCommonDataSource;
|
||||||
import com.gitee.dbswitch.data.domain.WrapHikariDataSource;
|
import com.gitee.dbswitch.data.domain.WrapHikariDataSource;
|
||||||
import com.gitee.dbswitch.data.entity.SourceDataSourceProperties;
|
import com.gitee.dbswitch.data.entity.SourceDataSourceProperties;
|
||||||
@@ -22,13 +22,10 @@ import com.gitee.dbswitch.data.entity.TargetDataSourceProperties;
|
|||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.sql.DataSource;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -135,7 +132,7 @@ public final class DataSourceUtils {
|
|||||||
// 如果是Greenplum数据库,这里需要关闭会话的查询优化器
|
// 如果是Greenplum数据库,这里需要关闭会话的查询优化器
|
||||||
if (properties.getDriverClassName().contains("postgresql")) {
|
if (properties.getDriverClassName().contains("postgresql")) {
|
||||||
try (Connection connection = dataSource.getConnection()) {
|
try (Connection connection = dataSource.getConnection()) {
|
||||||
if (DataSourceTypeUtils.isGreenplum(connection)) {
|
if (ProductTypeUtils.isGreenplum(connection)) {
|
||||||
ds.setConnectionInitSql("set optimizer to 'off'");
|
ds.setConnectionInitSql("set optimizer to 'off'");
|
||||||
log.info("Greenplum: Close Optimizer now: set optimizer to 'off'");
|
log.info("Greenplum: Close Optimizer now: set optimizer to 'off'");
|
||||||
}
|
}
|
||||||
@@ -228,20 +225,4 @@ public final class DataSourceUtils {
|
|||||||
return urlClassLoader;
|
return urlClassLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String executeStringReturnedSql(
|
|
||||||
DataSource dataSource, String sql) {
|
|
||||||
try (Connection connection = dataSource.getConnection()) {
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
|
||||||
try (ResultSet resultSet = statement.executeQuery(sql)) {
|
|
||||||
if (resultSet.next()) {
|
|
||||||
return resultSet.getString(1);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,40 +1,61 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.gitee.dbswitch</groupId>
|
<groupId>com.gitee.dbswitch</groupId>
|
||||||
<artifactId>dbswitch-parent</artifactId>
|
<artifactId>dbswitch-parent</artifactId>
|
||||||
<version>1.9.8</version>
|
<version>1.9.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>dbswitch-dist</artifactId>
|
<artifactId>dbswitch-dist</artifactId>
|
||||||
|
|
||||||
<build>
|
<properties>
|
||||||
<plugins>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<plugin>
|
<build>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<plugins>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<version>2.6</version>
|
<plugin>
|
||||||
<executions>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<execution>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<phase>package</phase>
|
<version>2.6</version>
|
||||||
<goals>
|
<executions>
|
||||||
<goal>single</goal>
|
<execution>
|
||||||
</goals>
|
<phase>package</phase>
|
||||||
<configuration>
|
<goals>
|
||||||
<finalName>dbswitch-release-${project.version}</finalName>
|
<goal>single</goal>
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
</goals>
|
||||||
<descriptors>
|
<configuration>
|
||||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
<finalName>dbswitch-release-${project.version}</finalName>
|
||||||
</descriptors>
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
<outputDirectory>${project.parent.basedir}/target/</outputDirectory>
|
<descriptors>
|
||||||
</configuration>
|
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||||
</execution>
|
</descriptors>
|
||||||
</executions>
|
<outputDirectory>${project.parent.basedir}/target/</outputDirectory>
|
||||||
</plugin>
|
</configuration>
|
||||||
</plugins>
|
</execution>
|
||||||
</build>
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
@@ -1,21 +0,0 @@
|
|||||||
// Copyright tang. All rights reserved.
|
|
||||||
// https://gitee.com/inrgihc/dbswitch
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style license
|
|
||||||
//
|
|
||||||
// Author: tang (inrgihc@126.com)
|
|
||||||
// Date : 2020/1/2
|
|
||||||
// Location: beijing , china
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
package com.gitee.dbswitch.product.greenplum;
|
|
||||||
|
|
||||||
import com.gitee.dbswitch.product.postgresql.PostgresTableCopyWriteProvider;
|
|
||||||
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
|
||||||
|
|
||||||
|
|
||||||
public class GreenPlumTableCopyWriteProvider extends PostgresTableCopyWriteProvider {
|
|
||||||
|
|
||||||
public GreenPlumTableCopyWriteProvider(ProductFactoryProvider factoryProvider) {
|
|
||||||
super(factoryProvider);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -12,6 +12,8 @@ package com.gitee.dbswitch.product.greenplum;
|
|||||||
import com.gitee.dbswitch.annotation.Product;
|
import com.gitee.dbswitch.annotation.Product;
|
||||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||||
import com.gitee.dbswitch.features.ProductFeatures;
|
import com.gitee.dbswitch.features.ProductFeatures;
|
||||||
|
import com.gitee.dbswitch.product.postgresql.PostgresTableCopyWriteProvider;
|
||||||
|
import com.gitee.dbswitch.product.postgresql.PostgresTableManageProvider;
|
||||||
import com.gitee.dbswitch.provider.AbstractFactoryProvider;
|
import com.gitee.dbswitch.provider.AbstractFactoryProvider;
|
||||||
import com.gitee.dbswitch.provider.manage.TableManageProvider;
|
import com.gitee.dbswitch.provider.manage.TableManageProvider;
|
||||||
import com.gitee.dbswitch.provider.meta.MetadataProvider;
|
import com.gitee.dbswitch.provider.meta.MetadataProvider;
|
||||||
@@ -39,14 +41,14 @@ public class GreenplumFactoryProvider extends AbstractFactoryProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableManageProvider createTableManageProvider() {
|
public TableManageProvider createTableManageProvider() {
|
||||||
return new GreenplumTableManageProvider(this);
|
return new PostgresTableManageProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableDataWriteProvider createTableDataWriteProvider(boolean useInsert) {
|
public TableDataWriteProvider createTableDataWriteProvider(boolean useInsert) {
|
||||||
return useInsert
|
return useInsert
|
||||||
? new AutoCastTableDataWriteProvider(this)
|
? new AutoCastTableDataWriteProvider(this)
|
||||||
: new GreenPlumTableCopyWriteProvider(this);
|
: new PostgresTableCopyWriteProvider(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,24 +19,19 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class GreenplumMetadataQueryProvider extends PostgresMetadataQueryProvider {
|
public class GreenplumMetadataQueryProvider extends PostgresMetadataQueryProvider {
|
||||||
|
|
||||||
|
|
||||||
public GreenplumMetadataQueryProvider(ProductFactoryProvider factoryProvider) {
|
public GreenplumMetadataQueryProvider(ProductFactoryProvider factoryProvider) {
|
||||||
super(factoryProvider);
|
super(factoryProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postAppendCreateTableSql(StringBuilder builder, String tblComment, List<String> primaryKeys,
|
public void postAppendCreateTableSql(StringBuilder builder, String tblComment, List<String> primaryKeys,
|
||||||
Map<String, String> tblProperties) {
|
Map<String, String> tblProperties) {
|
||||||
// 有主键就优先使用主键作为分布键。
|
// 有主键就优先使用主键作为分布键。
|
||||||
if (Objects.nonNull(primaryKeys) && !primaryKeys.isEmpty()) {
|
if (Objects.nonNull(primaryKeys) && !primaryKeys.isEmpty()) {
|
||||||
getPkOrDkAsString(builder, primaryKeys);
|
String pk = getPrimaryKeyAsString(primaryKeys);
|
||||||
|
builder.append("\n DISTRIBUTED BY (").append(pk).append(")");
|
||||||
log.info("using primary key as distributed key");
|
log.info("using primary key as distributed key");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPkOrDkAsString(StringBuilder builder, List<String> primaryKeys) {
|
|
||||||
String pk = getPrimaryKeyAsString(primaryKeys);
|
|
||||||
builder.append("\n DISTRIBUTED BY (").append(pk).append(")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
// Copyright tang. All rights reserved.
|
|
||||||
// https://gitee.com/inrgihc/dbswitch
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style license
|
|
||||||
//
|
|
||||||
// Author: tang (inrgihc@126.com)
|
|
||||||
// Date : 2020/1/2
|
|
||||||
// Location: beijing , china
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
package com.gitee.dbswitch.product.greenplum;
|
|
||||||
|
|
||||||
import com.gitee.dbswitch.product.postgresql.PostgresTableManageProvider;
|
|
||||||
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
|
||||||
import com.gitee.dbswitch.provider.manage.DefaultTableManageProvider;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class GreenplumTableManageProvider extends PostgresTableManageProvider {
|
|
||||||
|
|
||||||
public GreenplumTableManageProvider(ProductFactoryProvider factoryProvider) {
|
|
||||||
super(factoryProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -5,5 +5,5 @@ docker run -it --rm \
|
|||||||
-v ~/.m2:/opt/maven/localRepository \
|
-v ~/.m2:/opt/maven/localRepository \
|
||||||
-v "$PWD":/usr/src/mymaven \
|
-v "$PWD":/usr/src/mymaven \
|
||||||
-w /usr/src/mymaven \
|
-w /usr/src/mymaven \
|
||||||
inrgihc/maven-aliyun:3.6.3-jdk-8 mvn clean package
|
registry.cn-hangzhou.aliyuncs.com/inrgihc/maven-aliyun:3.6.3-jdk-8 mvn clean package
|
||||||
|
|
||||||
|
@@ -5,5 +5,5 @@ docker run -it --rm \
|
|||||||
-v ~/.m2:/opt/maven/localRepository \
|
-v ~/.m2:/opt/maven/localRepository \
|
||||||
-v "$PWD":/usr/src/mymaven \
|
-v "$PWD":/usr/src/mymaven \
|
||||||
-w /usr/src/mymaven \
|
-w /usr/src/mymaven \
|
||||||
inrgihc/maven-aliyun:3.6.3-jdk-8 mvn clean
|
registry.cn-hangzhou.aliyuncs.com/inrgihc/maven-aliyun:3.6.3-jdk-8 mvn clean
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user