Skip to content

Commit 77451fe

Browse files
authored
[HWORKS-1405] Get correct hive version in spark (#40)
1 parent f7b388a commit 77451fe

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/client/IsolatedClientLoader.scala

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,26 @@ private[hive] object IsolatedClientLoader extends Logging {
8989
}
9090

9191
def hiveVersion(version: String): HiveVersion = {
92-
// Fabio: Remove the last digit of the version string as it's the Hopsworks specific version
93-
version.substring(0, version.lastIndexOf(".")) match {
94-
case "12" | "0.12" | "0.12.0" => hive.v12
95-
case "13" | "0.13" | "0.13.0" | "0.13.1" => hive.v13
96-
case "14" | "0.14" | "0.14.0" => hive.v14
97-
case "1.0" | "1.0.0" | "1.0.1" => hive.v1_0
98-
case "1.1" | "1.1.0" | "1.1.1" => hive.v1_1
99-
case "1.2" | "1.2.0" | "1.2.1" | "1.2.2" => hive.v1_2
100-
case "2.0" | "2.0.0" | "2.0.1" => hive.v2_0
101-
case "2.1" | "2.1.0" | "2.1.1" => hive.v2_1
102-
case "2.2" | "2.2.0" => hive.v2_2
103-
case "2.3" | "2.3.0" | "2.3.1" | "2.3.2" | "2.3.3" | "2.3.4" | "2.3.5" | "2.3.6" | "2.3.7" =>
104-
hive.v2_3
105-
case "3.0" | "3.0.0" => hive.v3_0
106-
case "3.1" | "3.1.0" | "3.1.1" | "3.1.2" => hive.v3_1
107-
case version =>
108-
throw new UnsupportedOperationException(s"Unsupported Hive Metastore version ($version). " +
92+
def extractMajorMinorVersion(version: String): String = {
93+
val parts = version.split("\\.")
94+
if (parts.length >= 2) parts(0) + "." + parts(1) else parts(0)
95+
}
96+
97+
val majorMinorVersion = extractMajorMinorVersion(version)
98+
majorMinorVersion match {
99+
case "0.12" => hive.v12
100+
case "0.13" => hive.v13
101+
case "0.14" => hive.v14
102+
case "1.0" => hive.v1_0
103+
case "1.1" => hive.v1_1
104+
case "1.2" => hive.v1_2
105+
case "2.0" => hive.v2_0
106+
case "2.1" => hive.v2_1
107+
case "2.2" => hive.v2_2
108+
case "2.3" => hive.v2_3
109+
case "3.0" => hive.v3_0
110+
case "3.1" => hive.v3_1
111+
case _ => throw new UnsupportedOperationException(s"Unsupported Hive Metastore version ($version). " +
109112
s"Please set ${HiveUtils.HIVE_METASTORE_VERSION.key} with a valid version.")
110113
}
111114
}

0 commit comments

Comments
 (0)