-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
2,200 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.google.cloud.hive</groupId> | ||
<artifactId>hive-x-bigquery-connector</artifactId> | ||
<version>${revision}</version> | ||
<relativePath>../hive-x-bigquery-connector</relativePath> | ||
</parent> | ||
|
||
<artifactId>hive-1-bigquery-connector</artifactId> | ||
<name>Hive-BigQuery Connector For Hive 1.x.x</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>hive-bigquery-connector-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.cloud.bigdataoss</groupId> | ||
<artifactId>gcs-connector</artifactId> | ||
<classifier>shaded</classifier> | ||
</dependency> | ||
|
||
<!-- **************** Test dependencies **************** --> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>hive-bigquery-connector-common</artifactId> | ||
<version>${project.version}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.github.hiverunner</groupId> | ||
<artifactId>hiverunner</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<!-- Currently the same as "hive1.2.1-hadoop2.6.4" but could be changed later --> | ||
<!-- Use this profile if you don't care about specific minor versions of Hive 1.X --> | ||
<id>hive1-generic</id> | ||
<properties> | ||
<!-- | ||
As of the time of writing (August 2023), the latest GCS connector isn't | ||
compatible with Hadoop <= 2.7, so we use an older version | ||
--> | ||
<gcs-connector.version>hadoop2-2.2.3</gcs-connector.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>shaded-deps-hive1.2.1-hadoop2.6.4</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>shaded</classifier> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
<profile> | ||
<id>hive1.2.1-hadoop2.6.4</id> | ||
<properties> | ||
<!-- | ||
As of the time of writing (August 2023), the latest GCS connector isn't | ||
compatible with Hadoop <= 2.7, so we use an older version | ||
--> | ||
<gcs-connector.version>hadoop2-2.2.3</gcs-connector.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>shaded-deps-hive1.2.1-hadoop2.6.4</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>shaded</classifier> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>flatten-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
56 changes: 56 additions & 0 deletions
56
...nector/src/main/java/com/google/cloud/hive/bigquery/connector/BigQueryStorageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2023 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed 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.google.cloud.hive.bigquery.connector; | ||
|
||
import com.google.cloud.hive.bigquery.connector.output.PostInsertHook; | ||
import com.google.cloud.hive.bigquery.connector.output.PreInsertHook; | ||
import java.util.Map; | ||
import org.apache.hadoop.hive.conf.HiveConf; | ||
import org.apache.hadoop.hive.conf.HiveConf.ConfVars; | ||
import org.apache.hadoop.hive.metastore.HiveMetaHook; | ||
import org.apache.hadoop.hive.ql.plan.TableDesc; | ||
import org.apache.hadoop.hive.serde2.AbstractSerDe; | ||
|
||
public class BigQueryStorageHandler extends BigQueryStorageHandlerBase { | ||
|
||
@Override | ||
public HiveMetaHook getMetaHook() { | ||
return new Hive1BigQueryMetaHook(conf); | ||
} | ||
|
||
@Override | ||
public void configureOutputJobProperties(TableDesc tableDesc, Map<String, String> jobProperties) { | ||
super.configureOutputJobProperties(tableDesc, jobProperties); | ||
|
||
// In Hive 1, the metahook doesn't have a `preInsertTable()` method, so we use a | ||
// pre-execution hook instead | ||
addExecHook(ConfVars.PREEXECHOOKS.varname, PreInsertHook.class); | ||
|
||
String engine = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).toLowerCase(); | ||
if ((engine.equals("tez"))) { | ||
// Tez does not use the OutputCommitter (regardless of the Hive versions). | ||
// So with Hive 2 and 3, we override and use the metahook's `commitInsertTable()` method. | ||
// However, with Hive 1, that method isn't available. So we set up a post execution hook to | ||
// commit the writes. | ||
addExecHook(ConfVars.POSTEXECHOOKS.varname, PostInsertHook.class); | ||
} | ||
} | ||
|
||
@Override | ||
public Class<? extends AbstractSerDe> getSerDeClass() { | ||
return BigQuerySerDe.class; | ||
} | ||
} |
Oops, something went wrong.