Skip to content

Commit 1bd10ba

Browse files
committed
Wed Nov 30 13:24:29 PST 2016
1 parent 4162229 commit 1bd10ba

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/PartitionProviderCompatibilitySuite.scala

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,30 +231,32 @@ class PartitionProviderCompatibilitySuite
231231
assert(parts.contains("A=0/B=%3D"))
232232
assert(parts.contains("A=0/B=%25%3D"))
233233

234-
// custom locations sanity check
234+
// drop partition sanity check
235+
spark.sql("alter table test drop partition (A=1, B='%')")
236+
assert(spark.sql("select * from test").count() == 29) // 1 file in dropped partition
237+
235238
withTempDir { dir =>
239+
// custom locations sanity check
236240
spark.sql(s"""
237241
|alter table test partition (A=0, B='%')
238242
|set location '${dir.getAbsolutePath}'""".stripMargin)
239-
assert(spark.sql("select * from test").count() == 29) // missing 1
240-
}
243+
assert(spark.sql("select * from test").count() == 28) // moved to empty dir
241244

242-
// drop partition sanity check
243-
spark.sql("alter table test drop partition (A=1, B='%')")
244-
assert(spark.sql("select * from test").count() == 28)
245-
246-
// TODO(ekl) fix rename partition
247-
// withTempDir { dir =>
248-
// spark.sql(s"""
249-
// |alter table test partition (A=0, B='%')
250-
// |rename to partition (A=100, B='%')""".stripMargin)
251-
// assert(spark.sql("select * from test where a = 100").count() == 1)
252-
// }
253-
254-
// TODO(ekl) fix overwrite table
255-
// spark.sql("show partitions test").show(false)
256-
// spark.sql("insert overwrite table test partition (a, b) select id, id, '%' from range(1)")
257-
// assert(spark.sql("select * from test").count() == 1)
245+
// rename partition sanity check
246+
spark.sql(s"""
247+
|alter table test partition (A=5, B='%')
248+
|rename to partition (A=100, B='%')""".stripMargin)
249+
assert(spark.sql("select * from test where a = 5 and b = '%'").count() == 0)
250+
assert(spark.sql("select * from test where a = 100 and b = '%'").count() == 1)
251+
252+
// try with A=0 which has a custom location
253+
spark.sql("insert into test partition (A=0, B='%') select 1")
254+
spark.sql(s"""
255+
|alter table test partition (A=0, B='%')
256+
|rename to partition (A=101, B='%')""".stripMargin)
257+
assert(spark.sql("select * from test where a = 0 and b = '%'").count() == 0)
258+
assert(spark.sql("select * from test where a = 101 and b = '%'").count() == 1)
259+
}
258260
}
259261
}
260262
}

0 commit comments

Comments
 (0)