-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-17324] [SQL] Remove Direct Usage of HiveClient in InsertIntoHiveTable #14888
Closed
gatorsmile
wants to merge
3
commits into
apache:master
from
gatorsmile:removeClientFromInsertIntoHiveTable
Closed
Changes from 1 commit
Commits
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ case class InsertIntoHiveTable( | |
ifNotExists: Boolean) extends UnaryExecNode { | ||
|
||
@transient private val sessionState = sqlContext.sessionState.asInstanceOf[HiveSessionState] | ||
@transient private val client = sessionState.metadataHive | ||
@transient private val externalCatalog = sqlContext.sharedState.externalCatalog | ||
|
||
def output: Seq[Attribute] = Seq.empty | ||
|
||
|
@@ -240,54 +240,49 @@ case class InsertIntoHiveTable( | |
// holdDDLTime will be true when TOK_HOLD_DDLTIME presents in the query as a hint. | ||
val holdDDLTime = false | ||
if (partition.nonEmpty) { | ||
|
||
// loadPartition call orders directories created on the iteration order of the this map | ||
val orderedPartitionSpec = new util.LinkedHashMap[String, String]() | ||
table.hiveQlTable.getPartCols.asScala.foreach { entry => | ||
orderedPartitionSpec.put(entry.getName, partitionSpec.getOrElse(entry.getName, "")) | ||
} | ||
|
||
// inheritTableSpecs is set to true. It should be set to false for an IMPORT query | ||
// which is currently considered as a Hive native command. | ||
val inheritTableSpecs = true | ||
// TODO: Correctly set isSkewedStoreAsSubdir. | ||
val isSkewedStoreAsSubdir = false | ||
if (numDynamicPartitions > 0) { | ||
client.synchronized { | ||
client.loadDynamicPartitions( | ||
outputPath.toString, | ||
table.catalogTable.qualifiedName, | ||
orderedPartitionSpec, | ||
overwrite, | ||
numDynamicPartitions, | ||
holdDDLTime, | ||
isSkewedStoreAsSubdir) | ||
} | ||
externalCatalog.loadDynamicPartitions( | ||
db = table.catalogTable.database, | ||
table = table.catalogTable.identifier.table, | ||
outputPath.toString, | ||
partitionSpec, | ||
overwrite, | ||
numDynamicPartitions, | ||
holdDDLTime = holdDDLTime, | ||
listBucketingEnabled = false) | ||
} else { | ||
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. This TODO is removed. We set it in |
||
// scalastyle:off | ||
// ifNotExists is only valid with static partition, refer to | ||
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-InsertingdataintoHiveTablesfromqueries | ||
// scalastyle:on | ||
val oldPart = | ||
client.getPartitionOption( | ||
table.catalogTable, | ||
externalCatalog.getPartitionOption( | ||
table.catalogTable.database, | ||
table.catalogTable.identifier.table, | ||
partitionSpec) | ||
|
||
if (oldPart.isEmpty || !ifNotExists) { | ||
client.loadPartition( | ||
outputPath.toString, | ||
table.catalogTable.qualifiedName, | ||
orderedPartitionSpec, | ||
overwrite, | ||
holdDDLTime, | ||
inheritTableSpecs, | ||
isSkewedStoreAsSubdir) | ||
// TODO: Correctly set isSkewedStoreAsSubdir. | ||
val isSkewedStoreAsSubdir = false | ||
// inheritTableSpecs is set to true. It should be set to false for an IMPORT query | ||
// which is currently considered as a Hive native command. | ||
val inheritTableSpecs = true | ||
externalCatalog.loadPartition( | ||
table.catalogTable.database, | ||
table.catalogTable.identifier.table, | ||
outputPath.toString, | ||
partitionSpec, | ||
isOverwrite = overwrite, | ||
holdDDLTime = holdDDLTime, | ||
inheritTableSpecs = inheritTableSpecs, | ||
isSkewedStoreAsSubdir = isSkewedStoreAsSubdir) | ||
} | ||
} | ||
} else { | ||
client.loadTable( | ||
externalCatalog.loadTable( | ||
table.catalogTable.database, | ||
table.catalogTable.identifier.table, | ||
outputPath.toString, // TODO: URI | ||
table.catalogTable.qualifiedName, | ||
overwrite, | ||
holdDDLTime) | ||
} | ||
|
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.
where is
isSkewedStoreAsSubdir
parameter?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.
The last parameter of
loadDynamicPartitions
islistBucketingEnabled
.loadDynamicPartitions
does not have a parameter forisSkewedStoreAsSubdir
. Here, we fix a bug. : )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.
what's
listBucketingEnabled
used for? Will we need it in the future? If so, we also need to add a TODO hereThere 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.
Will answer the difference between
listBucketingEnabled
andisSkewedStoreAsSubdir
tomorrrow. Need more time to do the investigation. : )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.
uh...
isSkewedStoreAsSubdir
andlistBucketingEnabled
are the same!!!loadDynamicPartitions
is usinglistBucketingEnabled
, butloadPartition
is usingisSkewedStoreAsSubdir
.loadDynamicPartitions
eventually passes the value oflistBucketingEnabled
toisSkewedStoreAsSubdir
when callingloadPartition
.To differ list bucketing tables from normal skewed tables, they use an optional parameter
store as DIRECTORIES
. See the JIRA HIVE-3649.Actually, we can remove TODO for either
isSkewedStoreAsSubdir
orloadDynamicPartitions
, because we always ignore this feature ingetTableOption
. We can set it inHiveClientImpl
, and then we do not need to pollute the externalCatalog APIs