Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/9226#discussion_r54846913
--- Diff:
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala ---
@@ -218,25 +233,19 @@ private[hive] class HiveMetastoreCatalog(val client:
ClientInterface, hive: Hive
}
}
- val metastorePartitionColumns = userSpecifiedSchema.map { schema =>
- val fields = partitionColumns.map(col => schema(col))
- fields.map { field =>
- HiveColumn(
- name = field.name,
- hiveType = HiveMetastoreTypes.toMetastoreType(field.dataType),
- comment = "")
- }.toSeq
- }.getOrElse {
- if (partitionColumns.length > 0) {
- // The table does not have a specified schema, which means that
the schema will be inferred
- // when we load the table. So, we are not expecting partition
columns and we will discover
- // partitions when we load the table. However, if there are
specified partition columns,
- // we simply ignore them and provide a warning message.
- logWarning(
- s"The schema and partitions of table $tableIdent will be
inferred when it is loaded. " +
- s"Specified partition columns
(${partitionColumns.mkString(",")}) will be ignored.")
+ if (userSpecifiedSchema.isDefined && partitionColumns.length > 0) {
+ tableProperties.put("spark.sql.sources.schema.numPartCols",
partitionColumns.length.toString)
+ partitionColumns.zipWithIndex.foreach { case (partCol, index) =>
+ tableProperties.put(s"spark.sql.sources.schema.partCol.$index",
partCol)
}
- Seq.empty[HiveColumn]
+ } else {
+ // The table does not have a specified schema, which means that the
schema will be inferred
+ // when we load the table. So, we are not expecting partition
columns and we will discover
+ // partitions when we load the table. However, if there are
specified partition columns,
+ // we simply ignore them and provide a warning message.
+ logWarning(
+ s"The schema and partitions of table $tableIdent will be inferred
when it is loaded. " +
+ s"Specified partition columns
(${partitionColumns.mkString(",")}) will be ignored.")
--- End diff --
line 293 "partitionColumns = Nil" is after an asset:
`assert(partitionColumns.isEmpty)`.
We can not write out partitioned table in a hive compatible way, so I think
this PR is not the root cause that break your code.
But it's surprising that the written table is partitioned at hive side in
1.5.2, can you double check it?
---
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]