-
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-24360][SQL] Support Hive 3.1 metastore #23694
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ import org.apache.hadoop.hive.serde.serdeConstants | |
|
||
import org.apache.spark.internal.Logging | ||
import org.apache.spark.sql.AnalysisException | ||
import org.apache.spark.sql.SparkSession | ||
import org.apache.spark.sql.catalyst.FunctionIdentifier | ||
import org.apache.spark.sql.catalyst.analysis.NoSuchPermanentFunctionException | ||
import org.apache.spark.sql.catalyst.catalog.{CatalogFunction, CatalogTablePartition, CatalogUtils, FunctionResource, FunctionResourceType} | ||
|
@@ -1179,3 +1180,128 @@ private[client] class Shim_v2_1 extends Shim_v2_0 { | |
private[client] class Shim_v2_2 extends Shim_v2_1 | ||
|
||
private[client] class Shim_v2_3 extends Shim_v2_1 | ||
|
||
private[client] class Shim_v3_1 extends Shim_v2_3 { | ||
// Spark supports only non-ACID operations | ||
protected lazy val isAcidIUDoperation = JBoolean.FALSE | ||
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. @dongjoon-hyun, isn't it 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. Historically, In Hive code, else if(!isAcidIUDoperation && isFullAcidTable) {
destPath = fixFullAcidPathForLoadData(loadFileType, destPath, txnId, stmtId, tbl);
} And yes for your last question. We don't know the future of Hive. So, for the different parameter name, we had better handle differently. That was my logic. |
||
|
||
// Writer ID can be 0 for non-ACID operations | ||
protected lazy val writeIdInLoadTableOrPartition: JLong = 0L | ||
|
||
// Statement ID | ||
protected lazy val stmtIdInLoadTableOrPartition: JInteger = 0 | ||
|
||
protected lazy val listBucketingLevel: JInteger = 0 | ||
|
||
private lazy val clazzLoadFileType = getClass.getClassLoader.loadClass( | ||
"org.apache.hadoop.hive.ql.plan.LoadTableDesc$LoadFileType") | ||
|
||
private lazy val loadPartitionMethod = | ||
findMethod( | ||
classOf[Hive], | ||
"loadPartition", | ||
classOf[Path], | ||
classOf[Table], | ||
classOf[JMap[String, String]], | ||
clazzLoadFileType, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
classOf[JLong], | ||
JInteger.TYPE, | ||
JBoolean.TYPE) | ||
private lazy val loadTableMethod = | ||
findMethod( | ||
classOf[Hive], | ||
"loadTable", | ||
classOf[Path], | ||
classOf[String], | ||
clazzLoadFileType, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
JBoolean.TYPE, | ||
classOf[JLong], | ||
JInteger.TYPE, | ||
JBoolean.TYPE) | ||
private lazy val loadDynamicPartitionsMethod = | ||
findMethod( | ||
classOf[Hive], | ||
"loadDynamicPartitions", | ||
classOf[Path], | ||
classOf[String], | ||
classOf[JMap[String, String]], | ||
clazzLoadFileType, | ||
JInteger.TYPE, | ||
JInteger.TYPE, | ||
JBoolean.TYPE, | ||
JLong.TYPE, | ||
JInteger.TYPE, | ||
JBoolean.TYPE, | ||
classOf[AcidUtils.Operation], | ||
JBoolean.TYPE) | ||
|
||
override def loadPartition( | ||
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. checked |
||
hive: Hive, | ||
loadPath: Path, | ||
tableName: String, | ||
partSpec: JMap[String, String], | ||
replace: Boolean, | ||
inheritTableSpecs: Boolean, | ||
isSkewedStoreAsSubdir: Boolean, | ||
isSrcLocal: Boolean): Unit = { | ||
val session = SparkSession.getActiveSession | ||
assert(session.nonEmpty) | ||
val database = session.get.sessionState.catalog.getCurrentDatabase | ||
val table = hive.getTable(database, tableName) | ||
val loadFileType = if (replace) { | ||
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. checked |
||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("REPLACE_ALL")) | ||
} else { | ||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("KEEP_EXISTING")) | ||
} | ||
assert(loadFileType.isDefined) | ||
loadPartitionMethod.invoke(hive, loadPath, table, partSpec, loadFileType.get, | ||
inheritTableSpecs: JBoolean, isSkewedStoreAsSubdir: JBoolean, | ||
isSrcLocal: JBoolean, isAcid, hasFollowingStatsTask, | ||
writeIdInLoadTableOrPartition, stmtIdInLoadTableOrPartition, replace: JBoolean) | ||
} | ||
|
||
override def loadTable( | ||
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. checked |
||
hive: Hive, | ||
loadPath: Path, | ||
tableName: String, | ||
replace: Boolean, | ||
isSrcLocal: Boolean): Unit = { | ||
val loadFileType = if (replace) { | ||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("REPLACE_ALL")) | ||
} else { | ||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("KEEP_EXISTING")) | ||
} | ||
assert(loadFileType.isDefined) | ||
loadTableMethod.invoke(hive, loadPath, tableName, loadFileType.get, isSrcLocal: JBoolean, | ||
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. checked |
||
isSkewedStoreAsSubdir, isAcidIUDoperation, hasFollowingStatsTask, | ||
writeIdInLoadTableOrPartition, stmtIdInLoadTableOrPartition: JInteger, replace: JBoolean) | ||
} | ||
|
||
override def loadDynamicPartitions( | ||
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. checked |
||
hive: Hive, | ||
loadPath: Path, | ||
tableName: String, | ||
partSpec: JMap[String, String], | ||
replace: Boolean, | ||
numDP: Int, | ||
listBucketingEnabled: Boolean): Unit = { | ||
val loadFileType = if (replace) { | ||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("REPLACE_ALL")) | ||
} else { | ||
clazzLoadFileType.getEnumConstants.find(_.toString.equalsIgnoreCase("KEEP_EXISTING")) | ||
} | ||
assert(loadFileType.isDefined) | ||
loadDynamicPartitionsMethod.invoke(hive, loadPath, tableName, partSpec, loadFileType.get, | ||
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. checked |
||
numDP: JInteger, listBucketingLevel, isAcid, writeIdInLoadTableOrPartition, | ||
stmtIdInLoadTableOrPartition, hasFollowingStatsTask, AcidUtils.Operation.NOT_ACID, | ||
replace: JBoolean) | ||
} | ||
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. @dongjoon-hyun, not a big deal but how about adding 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. It's possible, but it doesn't help much. As we see here,
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. Yea, I noticed it. I am leaving this comment orthogonally just as a sanity check. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ private[hive] object IsolatedClientLoader extends Logging { | |
case "2.1" | "2.1.0" | "2.1.1" => hive.v2_1 | ||
case "2.2" | "2.2.0" => hive.v2_2 | ||
case "2.3" | "2.3.0" | "2.3.1" | "2.3.2" | "2.3.3" | "2.3.4" => hive.v2_3 | ||
case "3.1" | "3.1.0" | "3.1.1" => hive.v3_1 | ||
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. What is the reason we do not support 3.0? 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. It's not stable like Hadoop 3.0. Spark skipped Hadoop 3.0 and go with Hadoop 3.1. 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. I think we face the same issue in 1.0, 2.0, but we still support them. Could we simply support it and let the end-users decide it by themselves? 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. Then, hopefully, I can proceed that in another PR. |
||
case version => | ||
throw new UnsupportedOperationException(s"Unsupported Hive Metastore version ($version). " + | ||
s"Please set ${HiveUtils.HIVE_METASTORE_VERSION.key} with a valid version.") | ||
|
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.
I think it's fine if the signatures are matched and the tests pass. Let me double check them within tomorrow.
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.
Thanks!