Skip to content

Commit f471c4b

Browse files
committed
PreInsertionCasts should take table partitions into account
1 parent a132c80 commit f471c4b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
142142
val childOutputDataTypes = child.output.map(_.dataType)
143143
// Only check attributes, not partitionKeys since they are always strings.
144144
// TODO: Fully support inserting into partitioned tables.
145-
val tableOutputDataTypes = table.attributes.map(_.dataType)
145+
val tableOutputDataTypes =
146+
table.attributes.map(_.dataType) ++ table.partitionKeys.map(_.dataType)
146147

147148
if (childOutputDataTypes == tableOutputDataTypes) {
148149
p

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class HiveQuerySuite extends HiveComparisonTest {
167167

168168
createQueryTest("Cast Timestamp to Timestamp in UDF",
169169
"""
170-
| SELECT DATEDIFF(CAST(value AS timestamp), CAST('2002-03-21 00:00:00' AS timestamp))
170+
| SELECT DATEDIFF(CAST(value AS timestamp), CAST('2002-03-21 00:00:00' AS timestamp))
171171
| FROM src LIMIT 1
172172
""".stripMargin)
173173

0 commit comments

Comments
 (0)