Skip to content

Commit fd37123

Browse files
committed
Remove partition columns from partition metadata.
1 parent 6cbde33 commit fd37123

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/MetastoreRelation.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ private[hive] case class MetastoreRelation(
162162

163163
val sd = new org.apache.hadoop.hive.metastore.api.StorageDescriptor()
164164
tPartition.setSd(sd)
165-
sd.setCols(catalogTable.schema.map(toHiveColumn).asJava)
165+
166+
// Note: In Hive the schema and partition columns must be disjoint sets
167+
val schema = catalogTable.schema.map(toHiveColumn).filter { c =>
168+
!catalogTable.partitionColumnNames.contains(c.getName)
169+
}
170+
sd.setCols(schema.asJava)
171+
166172
p.storage.locationUri.foreach(sd.setLocation)
167173
p.storage.inputFormat.foreach(sd.setInputFormat)
168174
p.storage.outputFormat.foreach(sd.setOutputFormat)

0 commit comments

Comments
 (0)