-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-45265][SQL] Support Hive 4.0 metastore #48823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d13c97
[SPARK-45265][SQL] Support Hive Metastore Server 4.0
yaooqinn 88c4ea9
[SPARK-45265][SQL] Support Hive Metastore Server 4.0
yaooqinn 5b00926
fix CliSuites
yaooqinn f368ff1
response code
yaooqinn e71bd5f
timeout 240
yaooqinn c1e0380
Merge branch 'master' into SPARK-45265
yaooqinn e952423
Revert "timeout 240"
yaooqinn 24b4f58
getPartitionsByFilter LIKE wildcard
yaooqinn 3552e06
derby stackoverflow
yaooqinn f0c36b7
derby stackoverflow
yaooqinn 95e2e8f
Merge branch 'master' into SPARK-45265
yaooqinn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[SPARK-45265][SQL] Support Hive Metastore Server 4.0
- Loading branch information
commit 1d13c97121c412b499879d8bc271820dc58619fc
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.sql.hive.client | ||
|
|
||
| import java.io.PrintStream | ||
| import java.io.{OutputStream, PrintStream} | ||
| import java.lang.{Iterable => JIterable} | ||
| import java.lang.reflect.InvocationTargetException | ||
| import java.nio.charset.StandardCharsets.UTF_8 | ||
|
|
@@ -121,6 +121,7 @@ private[hive] class HiveClientImpl( | |
| case hive.v2_3 => new Shim_v2_3() | ||
| case hive.v3_0 => new Shim_v3_0() | ||
| case hive.v3_1 => new Shim_v3_1() | ||
| case hive.v4_0 => new Shim_v4_0() | ||
| } | ||
|
|
||
| // Create an internal session state for this HiveClientImpl. | ||
|
|
@@ -177,8 +178,10 @@ private[hive] class HiveClientImpl( | |
| // got changed. We reset it to clientLoader.ClassLoader here. | ||
| state.getConf.setClassLoader(clientLoader.classLoader) | ||
| shim.setCurrentSessionState(state) | ||
| state.out = new PrintStream(outputBuffer, true, UTF_8.name()) | ||
| state.err = new PrintStream(outputBuffer, true, UTF_8.name()) | ||
| val clz = state.getClass.getField("out").getType.asInstanceOf[Class[_ <: PrintStream]] | ||
| val ctor = clz.getConstructor(classOf[OutputStream], classOf[Boolean], classOf[String]) | ||
| state.getClass.getField("out").set(state, ctor.newInstance(outputBuffer, true, UTF_8.name())) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. build fail : ”the result type of an implicit conversion must be more specific than Object“ |
||
| state.getClass.getField("err").set(state, ctor.newInstance(outputBuffer, true, UTF_8.name())) | ||
| state | ||
| } | ||
|
|
||
|
|
@@ -307,15 +310,27 @@ private[hive] class HiveClientImpl( | |
| } | ||
|
|
||
| def setOut(stream: PrintStream): Unit = withHiveState { | ||
| state.out = stream | ||
| val ctor = state.getClass.getField("out") | ||
| .getType | ||
| .asInstanceOf[Class[_ <: PrintStream]] | ||
| .getConstructor(classOf[OutputStream]) | ||
| state.getClass.getField("out").set(state, ctor.newInstance(stream)) | ||
| } | ||
|
|
||
| def setInfo(stream: PrintStream): Unit = withHiveState { | ||
| state.info = stream | ||
| val ctor = state.getClass.getField("info") | ||
| .getType | ||
| .asInstanceOf[Class[_ <: PrintStream]] | ||
| .getConstructor(classOf[OutputStream]) | ||
| state.getClass.getField("info").set(state, ctor.newInstance(stream)) | ||
| } | ||
|
|
||
| def setError(stream: PrintStream): Unit = withHiveState { | ||
| state.err = stream | ||
| val ctor = state.getClass.getField("err") | ||
| .getType | ||
| .asInstanceOf[Class[_ <: PrintStream]] | ||
| .getConstructor(classOf[OutputStream]) | ||
| state.getClass.getField("err").set(state, ctor.newInstance(stream)) | ||
| } | ||
|
|
||
| private def setCurrentDatabaseRaw(db: String): Unit = { | ||
|
|
@@ -629,21 +644,22 @@ private[hive] class HiveClientImpl( | |
| } | ||
|
|
||
| override def createPartitions( | ||
| db: String, | ||
| table: String, | ||
| table: CatalogTable, | ||
| parts: Seq[CatalogTablePartition], | ||
| ignoreIfExists: Boolean): Unit = withHiveState { | ||
| def replaceExistException(e: Throwable): Unit = e match { | ||
| case _: HiveException if e.getCause.isInstanceOf[AlreadyExistsException] => | ||
| val hiveTable = client.getTable(db, table) | ||
| val db = table.identifier.database.getOrElse(state.getCurrentDatabase) | ||
| val tableName = table.identifier.table | ||
| val hiveTable = client.getTable(db, tableName) | ||
| val existingParts = parts.filter { p => | ||
| shim.getPartitions(client, hiveTable, p.spec.asJava).nonEmpty | ||
| } | ||
| throw new PartitionsAlreadyExistException(db, table, existingParts.map(_.spec)) | ||
| throw new PartitionsAlreadyExistException(db, tableName, existingParts.map(_.spec)) | ||
| case _ => throw e | ||
| } | ||
| try { | ||
| shim.createPartitions(client, db, table, parts, ignoreIfExists) | ||
| shim.createPartitions(client, toHiveTable(table), parts, ignoreIfExists) | ||
| } catch { | ||
| case e: InvocationTargetException => replaceExistException(e.getCause) | ||
| case e: Throwable => replaceExistException(e) | ||
|
|
@@ -891,17 +907,14 @@ private[hive] class HiveClientImpl( | |
| results | ||
|
|
||
| case _ => | ||
| if (state.out != null) { | ||
| val out = state.getClass.getField("out").get(state) | ||
| if (out != null) { | ||
| // scalastyle:off println | ||
| state.out.println(tokens(0) + " " + cmd_1) | ||
| out.asInstanceOf[PrintStream].println(tokens(0) + " " + cmd_1) | ||
| // scalastyle:on println | ||
| } | ||
| val response: CommandProcessorResponse = proc.run(cmd_1) | ||
| // Throw an exception if there is an error in query processing. | ||
| if (response.getResponseCode != 0) { | ||
| throw new QueryExecutionException(response.getErrorMessage) | ||
| } | ||
| Seq(response.getResponseCode.toString) | ||
| proc.run(cmd_1) | ||
| Seq("0") | ||
| } | ||
| } catch { | ||
| case e: Exception => | ||
|
|
@@ -971,7 +984,7 @@ private[hive] class HiveClientImpl( | |
| partSpec, | ||
| replace, | ||
| numDP, | ||
| listBucketingEnabled = hiveTable.isStoredAsSubDirectories) | ||
| hiveTable) | ||
| } | ||
|
|
||
| override def createFunction(db: String, func: CatalogFunction): Unit = withHiveState { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?