提交 5759751b authored 作者: 李纤's avatar 李纤

Merge remote-tracking branch 'origin/master'

......@@ -992,39 +992,39 @@
<!-- <target>${maven.compiler.target}</target>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.3.RELEASE</version>
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>1.3.3.RELEASE</version>-->
<!-- <configuration>-->
<!-- <mainClass>none</mainClass>-->
<!-- &lt;!&ndash; 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 &ndash;&gt;-->
<!--&lt;!&ndash; <classifier>execute</classifier>&ndash;&gt;-->
<!-- &lt;!&ndash; 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) &ndash;&gt;-->
<!-- </configuration>-->
<!-- <dependencies>-->
<!-- spring 热部署 -->
<!-- &lt;!&ndash; spring 热部署 &ndash;&gt;-->
<dependency>
<!-- <dependency>-->
<groupId>org.springframework</groupId>
<!-- <groupId>org.springframework</groupId>-->
<artifactId>springloaded</artifactId>
<!-- <artifactId>springloaded</artifactId>-->
<version>1.2.8.RELEASE</version>
<!-- <version>1.2.8.RELEASE</version>-->
</dependency>
<!-- </dependency>-->
</dependencies>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- </dependencies>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>repackage</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
......@@ -1047,7 +1047,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1087,7 +1087,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1167,7 +1167,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1214,7 +1214,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1268,7 +1268,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1441,7 +1441,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......@@ -1498,7 +1498,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......
......@@ -60,7 +60,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
......
......@@ -30,7 +30,7 @@ import java.util.Set;
@AutoService(DataSourceFactory.class)
public class CSVDataSourceFactory implements DataSourceFactory {
private static final String PLUGIN_NAME = "S3";
private static final String PLUGIN_NAME = "CSV";
@Override
public String factoryIdentifier() {
......
......@@ -82,7 +82,11 @@ public class CSVOptionRule {
.stringType()
.defaultValue("csv")
.withDescription("S3 write type");
public static final Option<FileFormat> FILENAME =
Options.key("file_name")
.enumType(FileFormat.class)
.noDefaultValue()
.withDescription("S3 write type");
public static final Option<String> DELIMITER =
Options.key("delimiter")
.stringType()
......@@ -150,13 +154,8 @@ public class CSVOptionRule {
}
public enum FileFormat {
CSV("csv"),
TEXT("txt"),
PARQUET("parquet"),
ORC("orc"),
JSON("json"),
CSV("csv");
XML("xml");
private final String type;
FileFormat(String type) {
......
......@@ -30,7 +30,7 @@ import java.util.Set;
@AutoService(DataSourceFactory.class)
public class ExcelDataSourceFactory implements DataSourceFactory {
private static final String PLUGIN_NAME = "S3";
private static final String PLUGIN_NAME = "Excel";
@Override
public String factoryIdentifier() {
......
......@@ -84,6 +84,11 @@ public class ExcelOptionRule {
.noDefaultValue()
.withDescription("S3 write type");
public static final Option<FileFormat> FILENAME =
Options.key("fileName")
.enumType(FileFormat.class)
.noDefaultValue()
.withDescription("S3 write type");
public static final Option<String> DELIMITER =
Options.key("delimiter")
.stringType()
......@@ -126,6 +131,7 @@ public class ExcelOptionRule {
.optional(DATE_FORMAT)
.optional(DATETIME_FORMAT)
.optional(TIME_FORMAT)
.optional(FILENAME)
.build();
}
......
......@@ -21,7 +21,6 @@ import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.datasource.plugin.api.DataSourceChannelExt;
import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginException;
import org.apache.seatunnel.datasource.plugin.api.model.TableField;
import org.apache.seatunnel.datasource.plugin.api.utils.JdbcUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -130,39 +129,7 @@ public class PostgresqlDataSourceChannel implements DataSourceChannelExt {
"Postgresql tableName should composed by schemaName.tableName");
}
try (ResultSet resultSet = metaData.getColumns(database, split[0], split[1], null)) {
while (resultSet.next()) {
TableField tableField = new TableField();
String columnName = resultSet.getString("COLUMN_NAME");
tableField.setPrimaryKey(false);
if (StringUtils.isNotBlank(primaryKey) && primaryKey.equals(columnName)) {
tableField.setPrimaryKey(true);
}
tableField.setType(resultSet.getString("TYPE_NAME"));
// if (typeList.contains(tableField.getType().toLowerCase()))
// {
// tableField.setLen(resultSet.getString("CHARACTER_MAXIMUM_LENGTH"));
// } else {
//
// tableField.setLen(resultSet.getString("NUMERIC_PRECISION"));
//
// tableField.setScale(resultSet.getString("NUMERIC_SCALE"));
// }
// String extra = resultSet.getString("EXTRA");
// if (StringUtils.isNotBlank(extra)) {
// tableField.setHasAutoIncrement(true);
// }
tableField.setName(columnName);
tableField.setComment(resultSet.getString("REMARKS"));
//
// tableField.setDefaultValue(resultSet.getString("COLUMN_DEFAULT"));
Object nullable = resultSet.getObject("IS_NULLABLE");
//
// tableField.setNullable(Boolean.TRUE.toString().equals(nullable.toString()));
tableFields.add(tableField);
}
getFileds(tableFields, primaryKey, resultSet);
}
} catch (SQLException | ClassNotFoundException e) {
throw new DataSourcePluginException("get table fields failed", e);
......@@ -170,6 +137,36 @@ public class PostgresqlDataSourceChannel implements DataSourceChannelExt {
return tableFields;
}
private static void getFileds(
List<TableField> tableFields, String primaryKey, ResultSet resultSet)
throws SQLException {
while (resultSet.next()) {
TableField tableField = new TableField();
String nullable = resultSet.getString("IS_NULLABLE");
if ("YES".equals(nullable.toUpperCase())) {
tableField.setNullable(true);
} else {
tableField.setNullable(false);
}
String columnName = resultSet.getString("COLUMN_NAME");
tableField.setPrimaryKey(false);
if (StringUtils.isNotBlank(primaryKey) && primaryKey.equals(columnName)) {
tableField.setPrimaryKey(true);
}
String typeName = resultSet.getString("TYPE_NAME");
System.out.println(typeName);
tableField.setType(typeName);
tableField.setName(columnName);
String remarks = resultSet.getString("REMARKS");
tableField.setComment(remarks);
tableFields.add(tableField);
}
}
@Override
public Map<String, List<TableField>> getTableFields(
@NonNull String pluginName,
......@@ -197,9 +194,20 @@ public class PostgresqlDataSourceChannel implements DataSourceChannelExt {
throws SQLException, ClassNotFoundException {
checkNotNull(requestParams.get(PostgresqlOptionRule.DRIVER.key()));
checkNotNull(requestParams.get(PostgresqlOptionRule.URL.key()), "Jdbc url cannot be null");
String url =
JdbcUtils.replaceDatabase(
requestParams.get(PostgresqlOptionRule.URL.key()), databaseName);
String url = requestParams.get(PostgresqlOptionRule.URL.key());
String driver = requestParams.get(PostgresqlOptionRule.DRIVER.key());
if (StringUtils.isEmpty(driver)) {
driver = "org.postgresql.Driver";
}
Class Clazz = Class.forName(driver);
Driver driverInstance = null;
try {
driverInstance = (Driver) Clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
DriverManager.registerDriver(driverInstance);
if (requestParams.containsKey(PostgresqlOptionRule.USER.key())) {
String username = requestParams.get(PostgresqlOptionRule.USER.key());
String password = requestParams.get(PostgresqlOptionRule.PASSWORD.key());
......
......@@ -83,7 +83,11 @@ public class S3OptionRule {
.enumType(FileFormat.class)
.noDefaultValue()
.withDescription("S3 write type");
public static final Option<FileFormat> FILENAME =
Options.key("file_name")
.enumType(FileFormat.class)
.noDefaultValue()
.withDescription("S3 write type");
public static final Option<String> DELIMITER =
Options.key("delimiter")
.stringType()
......
......@@ -67,7 +67,7 @@
<configuration>
<mainClass>none</mainClass>
<!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
<classifier>execute</classifier>
<!-- <classifier>execute</classifier>-->
<!-- 解决maven-plugin插件打的Jar包可以运行,但依赖方打包找不到此模块中的类或属性的问题(程序包xxx不存在) -->
</configuration>
<dependencies>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论