Github user tejasapatil commented on a diff in the pull request:
https://github.com/apache/spark/pull/17644#discussion_r116384127
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/InsertIntoHiveTable.scala
---
@@ -307,6 +307,27 @@ case class InsertIntoHiveTable(
}
}
+ table.bucketSpec match {
+ case Some(bucketSpec) =>
+ // Writes to bucketed hive tables are allowed only if user does
not care about maintaining
+ // table's bucketing ie. both "hive.enforce.bucketing" and
"hive.enforce.sorting" are
+ // set to false
+ val enforceBucketingConfig = "hive.enforce.bucketing"
+ val enforceSortingConfig = "hive.enforce.sorting"
+
+ val message = s"Output Hive table ${table.identifier} is bucketed
but Spark" +
+ "currently does NOT populate bucketed output which is compatible
with Hive."
+
+ if (hadoopConf.get(enforceBucketingConfig, "true").toBoolean ||
+ hadoopConf.get(enforceSortingConfig, "true").toBoolean) {
+ throw new AnalysisException(message)
+ } else {
+ logWarning(message + s" Inserting data anyways since both
$enforceBucketingConfig and " +
+ s"$enforceSortingConfig are set to false.")
--- End diff --
- In Hive 1.x:
- If enforcing configs are set: data is populated respecting the tables'
bucketing spec
- If enforcing configs are NOT set: data is populated and not conformant
with the tables' bucketing spec
- In Hive 2.x, these configs are not there and hive would always populate
data conformant with table's bucketing.
With Spark, currently the data would be written out in a non conformant way
despite of that config being set or not. This PR will go to the model of Hive
1.x. I am working on a next PR which would make things like Hive 2.0.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]