Skip to content

Commit

Permalink
[feature] datatype convtor and switcher and add hive (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoJiang521 authored Aug 25, 2023
1 parent f3b8f64 commit 8780674
Show file tree
Hide file tree
Showing 53 changed files with 1,375 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ protected AbstractDataSourceClient() {
for (String pluginName : DatasourceLoadConfig.pluginSet) {
log.info("plugin set : " + pluginName);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getCustomClassloader(pluginName));
if (DatasourceLoadConfig.classLoaderChannel.get(pluginName.toUpperCase()) != null) {
log.info(pluginName + " is exist");
continue;
}
Thread.currentThread().setContextClassLoader(getCustomClassloader(pluginName));
try {
Class<?> clazz =
Class.forName(
Expand Down Expand Up @@ -249,7 +249,11 @@ private ClassLoader getCustomClassloader(String pluginName) {
});

log.info("jar file length :" + (jarFiles == null ? 0 : jarFiles.length));
log.info("jar file length :" + (jarFiles == null ? 0 : jarFiles[0].getName()));
log.info(
"jar file name :"
+ (jarFiles == null
? 0
: jarFiles.length == 0 ? "no jar" : jarFiles[0].getName()));
DatasourceClassLoader customClassLoader =
DatasourceLoadConfig.datasourceClassLoaders.get(pluginName.toUpperCase());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {

@Override
public URL getResource(String name) {
log.info("getResource : " + name);
// first, try and find it via the URLClassloader
URL urlClassLoaderResource = findResource(name);
if (urlClassLoaderResource != null) {
Expand All @@ -79,7 +78,6 @@ public URL getResource(String name) {
@Override
public Enumeration<URL> getResources(String name) throws IOException {
// first get resources from URLClassloader
log.info("getResources : " + name);
Enumeration<URL> urlClassLoaderResources = findResources(name);
final List<URL> result = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class DatasourceLoadConfig {
"JDBC-CLICKHOUSE",
"org.apache.seatunnel.datasource.plugin.clickhouse.jdbc.ClickhouseJdbcDataSourceFactory");
classLoaderFactoryName.put(
"HIVE",
"org.apache.seatunnel.datasource.plugin.hive.jdbc.HiveJdbcDataSourceFactory");
"HIVE", "com.whaleops.datasource.datasource.plugin.hive.HiveDataSourceFactory");
classLoaderFactoryName.put(
"JDBC-ORACLE",
"org.apache.seatunnel.datasource.plugin.oracle.jdbc.OracleJdbcDataSourceFactory");
Expand Down Expand Up @@ -107,7 +106,7 @@ public class DatasourceLoadConfig {

classLoaderJarName.put("ELASTICSEARCH", "datasource-elasticsearch-");
classLoaderJarName.put("S3", "datasource-s3-");
classLoaderJarName.put("HIVE", "datasource-jdbc-hive-");
classLoaderJarName.put("HIVE", "datasource-hive-");
classLoaderJarName.put("KAFKA", "datasource-kafka-");
classLoaderJarName.put("STARROCKS", "datasource-starrocks-");
classLoaderJarName.put("S3-REDSHIFT", "datasource-s3redshift-");
Expand All @@ -122,13 +121,11 @@ public class DatasourceLoadConfig {
"Hive",
"JDBC-Oracle",
"JDBC-Postgres",
"JDBC-Redshift",
"JDBC-SQLServer",
"JDBC-TiDB",
"Kafka",
"MySQL-CDC",
"S3",
"S3-Redshift",
"SqlServer-CDC",
"JDBC-StarRocks",
"StarRocks");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,22 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>${e2e.dependency.skip}</skip>
<appendOutput>true</appendOutput>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-datasource-plugins</artifactId>
<version>${revision}</version>
</parent>

<artifactId>datasource-hive</artifactId>

<properties>
<hive.exec.version>3.1.3</hive.exec.version>
<guava.version>24.1-jre</guava.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>datasource-plugins-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-hadoop3-3.1.4-uber</artifactId>
<version>2.3.2</version>
<classifier>optional</classifier>
<exclusions>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.exec.version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-hadoop-bundle</artifactId>
</exclusion>
<exclusion>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
</exclusion>
<exclusion>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>${e2e.dependency.skip}</skip>
<appendOutput>true</appendOutput>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.whaleops.datasource.datasource.plugin.hive;

import org.apache.seatunnel.api.configuration.util.OptionRule;
import org.apache.seatunnel.datasource.plugin.api.DataSourcePluginInfo;
import org.apache.seatunnel.datasource.plugin.api.DatasourcePluginTypeEnum;

import com.google.common.collect.Sets;

import java.util.Set;

public class HiveConfig {
public static final String PLUGIN_NAME = "Hive";

public static final DataSourcePluginInfo HIVE_DATASOURCE_PLUGIN_INFO =
DataSourcePluginInfo.builder()
.name(PLUGIN_NAME)
.icon(PLUGIN_NAME)
.version("1.0.0")
.type(DatasourcePluginTypeEnum.DATABASE.getCode())
.build();

public static final Set<String> HIVE_SYSTEM_DATABASES = Sets.newHashSet();

public static final OptionRule OPTION_RULE =
OptionRule.builder().required(HiveOptionRule.METASTORE_URI).build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.whaleops.datasource.datasource.plugin.hive;

import com.google.common.collect.Sets;

import java.util.Set;

public class HiveConstants {

public static final Set<String> HIVE_SYSTEM_DATABASES =
Sets.newHashSet(
"information_schema", "mysql", "performance_schema", "sys", "test", "hivedb");
}
Loading

0 comments on commit 8780674

Please sign in to comment.