Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/9226#discussion_r54847179
--- 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 --
The root cause is line 270. Even in non-hive compatible mode, we still keep
partition info in hive metadata before. This PR changed it and store partition
info as properties.
We can't write out partitioned table in a hive-compatible way, so I think
it's a safe change, you can't query that table at hive side anyway.
---
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]