Skip to content

Commit d421c98

Browse files
authored
Upgrade HCatalogIO to Hive 4.0.1 (#36901)
1 parent db09899 commit d421c98

File tree

6 files changed

+18
-54
lines changed

6 files changed

+18
-54
lines changed

.github/workflows/beam_PreCommit_Java_HCatalog_IO_Direct.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,13 @@ jobs:
8787
github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }})
8888
- name: Setup environment
8989
uses: ./.github/actions/setup-environment-action
90-
with:
91-
java-version: |
92-
8
93-
11
9490
- name: run HCatalog IO build script
9591
uses: ./.github/actions/gradle-command-self-hosted-action
9692
with:
9793
gradle-command: :sdks:java:io:hcatalog:build
9894
arguments: |
9995
-PdisableSpotlessCheck=true \
10096
-PdisableCheckStyle=true \
101-
# TODO(https://github.com/apache/beam/issues/32189) remove when embedded hive supports Java11
102-
- name: Test HCatalog IO on Java8
103-
uses: ./.github/actions/gradle-command-self-hosted-action
104-
with:
105-
gradle-command: :sdks:java:io:hcatalog:test
106-
arguments: |
107-
-PdisableSpotlessCheck=true \
108-
-PdisableCheckStyle=true \
109-
-Dfile.encoding=UTF-8 \
110-
-PtestJavaVersion=8 \
111-
-Pjava8Home=$JAVA_HOME_8_X64 \
11297
- name: Archive JUnit Test Results
11398
uses: actions/upload-artifact@v4
11499
if: ${{ !success() }}

.github/workflows/beam_PreCommit_Java_IOs_Direct.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ jobs:
8888
github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }})
8989
- name: Setup environment
9090
uses: ./.github/actions/setup-environment-action
91-
with:
92-
java-version: |
93-
8
94-
11
9591
- name: run Java IOs PreCommit script
9692
uses: ./.github/actions/gradle-command-self-hosted-action
9793
with:
@@ -100,17 +96,6 @@ jobs:
10096
-PdisableSpotlessCheck=true \
10197
-PdisableCheckStyle=true \
10298
-Dfile.encoding=UTF-8 \
103-
# TODO(https://github.com/apache/beam/issues/32189) remove when embedded hive supports Java11
104-
- name: run Java8 IOs PreCommit script
105-
uses: ./.github/actions/gradle-command-self-hosted-action
106-
with:
107-
gradle-command: :sdks:java:io:hcatalog:build
108-
arguments: |
109-
-PdisableSpotlessCheck=true \
110-
-PdisableCheckStyle=true \
111-
-Dfile.encoding=UTF-8 \
112-
-PtestJavaVersion=8 \
113-
-Pjava8Home=$JAVA_HOME_8_X64 \
11499
- name: Archive JUnit Test Results
115100
uses: actions/upload-artifact@v4
116101
if: ${{ !success() }}

sdks/java/extensions/sql/hcatalog/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ applyJavaNature(
2525
],
2626
)
2727

28-
def hive_version = "3.1.3"
28+
def hive_version = "4.0.1"
2929
def netty_version = "4.1.110.Final"
3030

3131
/*
@@ -42,7 +42,7 @@ dependencies {
4242
implementation project(":sdks:java:io:hcatalog")
4343
implementation project(":sdks:java:core")
4444
implementation library.java.vendored_guava_32_1_2_jre
45-
45+
testImplementation library.java.junit
4646
testImplementation project(":sdks:java:io:hcatalog").sourceSets.test.output
4747
// Needed for HCatalogTableProvider tests,
4848
// they use HCat* types

sdks/java/io/hcatalog/build.gradle

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ applyJavaNature(
2929
description = "Apache Beam :: SDKs :: Java :: IO :: HCatalog"
3030
ext.summary = "IO to read and write for HCatalog source."
3131

32+
// hive 4.x is compatible with Hadoop 3.x; Hive 3.x has been EOL as of Oct 2024
3233
def hadoopVersions = [
33-
"2102": "2.10.2",
3434
"324": "3.2.4",
3535
"336": "3.3.6",
3636
// "341": "3.4.1", // tests already exercised on the default version
3737
]
3838

3939
hadoopVersions.each {kv -> configurations.create("hadoopVersion$kv.key")}
4040

41-
def hive_version = "3.1.3"
41+
def hive_version = "4.0.1"
4242

4343
dependencies {
4444
implementation library.java.vendored_guava_32_1_2_jre
@@ -64,6 +64,10 @@ dependencies {
6464
testImplementation library.java.hamcrest
6565
testImplementation "org.apache.hive.hcatalog:hive-hcatalog-core:$hive_version:tests"
6666
testImplementation "org.apache.hive:hive-exec:$hive_version"
67+
// datanucleus dependency version should be in alignment with managed dependencies of hive-standalone-metastore
68+
testRuntimeOnly 'org.datanucleus:datanucleus-api-jdo:5.2.8'
69+
testRuntimeOnly 'org.datanucleus:datanucleus-rdbms:5.2.10'
70+
testRuntimeOnly 'org.datanucleus:javax.jdo:3.2.0-release'
6771
testImplementation "org.apache.hive:hive-common:$hive_version"
6872
testImplementation "org.apache.hive:hive-cli:$hive_version"
6973
testImplementation "org.apache.hive.hcatalog:hive-hcatalog-core:$hive_version"
@@ -105,14 +109,3 @@ hadoopVersions.each { kv ->
105109
include '**/*Test.class'
106110
}
107111
}
108-
109-
project.tasks.withType(Test).configureEach {
110-
if (JavaVersion.VERSION_1_8.compareTo(JavaVersion.current()) < 0 && project.findProperty('testJavaVersion') != '8') {
111-
useJUnit {
112-
filter {
113-
excludeTestsMatching "org.apache.beam.sdk.io.hcatalog.HCatalogIOTest"
114-
excludeTestsMatching "org.apache.beam.sdk.io.hcatalog.HCatalogBeamSchemaTest"
115-
}
116-
}
117-
}
118-
}

sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public Read withTerminationCondition(TerminationCondition<Read, ?> terminationCo
258258
}
259259

260260
Read withSplitId(int splitId) {
261-
checkArgument(splitId >= 0, "Invalid split id-%s", splitId);
261+
checkArgument(splitId >= 0, "Invalid split id-" + splitId);
262262
return toBuilder().setSplitId(splitId).build();
263263
}
264264

sdks/java/io/hcatalog/src/test/java/org/apache/beam/sdk/io/hcatalog/test/EmbeddedMetastoreService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.apache.hadoop.hive.conf.HiveConf;
2929
import org.apache.hadoop.hive.ql.DriverFactory;
3030
import org.apache.hadoop.hive.ql.IDriver;
31-
import org.apache.hadoop.hive.ql.processors.CommandProcessorResponse;
31+
import org.apache.hadoop.hive.ql.processors.CommandProcessorException;
3232
import org.apache.hadoop.hive.ql.session.SessionState;
3333

3434
/**
@@ -58,11 +58,11 @@ public EmbeddedMetastoreService(String baseDirPath) throws IOException {
5858
String testWarehouseDirPath = makePathASafeFileName(testDataDirPath + "/warehouse");
5959

6060
hiveConf = new HiveConf(getClass());
61-
hiveConf.setVar(HiveConf.ConfVars.PREEXECHOOKS, "");
62-
hiveConf.setVar(HiveConf.ConfVars.POSTEXECHOOKS, "");
61+
hiveConf.setVar(HiveConf.ConfVars.PRE_EXEC_HOOKS, "");
62+
hiveConf.setVar(HiveConf.ConfVars.POST_EXEC_HOOKS, "");
6363
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
64-
hiveConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, testWarehouseDirPath);
65-
hiveConf.setBoolVar(HiveConf.ConfVars.HIVEOPTIMIZEMETADATAQUERIES, true);
64+
hiveConf.setVar(HiveConf.ConfVars.METASTORE_WAREHOUSE, testWarehouseDirPath);
65+
hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_OPTIMIZE_METADATA_QUERIES, true);
6666
hiveConf.setVar(
6767
HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
6868
"org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider");
@@ -75,9 +75,10 @@ public EmbeddedMetastoreService(String baseDirPath) throws IOException {
7575

7676
/** Executes the passed query on the embedded metastore service. */
7777
public void executeQuery(String query) {
78-
CommandProcessorResponse response = driver.run(query);
79-
if (response.failed()) {
80-
throw new RuntimeException(response.getException());
78+
try {
79+
driver.run(query);
80+
} catch (CommandProcessorException e) {
81+
throw new RuntimeException(e);
8182
}
8283
}
8384

0 commit comments

Comments
 (0)