aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorMichael Armbrust <michael@databricks.com>2015-03-31 11:34:29 -0700
committerMichael Armbrust <michael@databricks.com>2015-03-31 11:34:52 -0700
commitbeebb7ffc21c66ae3e4c615555194d1e19ede1bb (patch)
tree83dd08c4f63010589de1a72c83dcf3c785e93c93 /sql/hive
parentb5bd75d90a761199c3f9cb583c1fe48c8fda7780 (diff)
downloadspark-beebb7ffc21c66ae3e4c615555194d1e19ede1bb.tar.gz
spark-beebb7ffc21c66ae3e4c615555194d1e19ede1bb.tar.bz2
spark-beebb7ffc21c66ae3e4c615555194d1e19ede1bb.zip
[SPARK-5371][SQL] Propagate types after function conversion, before futher resolution
Before it was possible for a query to flip back and forth from a resolved state, allowing resolution to propagate up before coercion had stabilized. The issue was that `ResolvedReferences` would run after `FunctionArgumentConversion`, but before `PropagateTypes` had run. This PR ensures we correctly `PropagateTypes` after any coercion has applied. Author: Michael Armbrust <michael@databricks.com> Closes #5278 from marmbrus/unionNull and squashes the following commits: dc3581a [Michael Armbrust] [SPARK-5371][SQL] Propogate types after function conversion / before futher resolution
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala26
1 files changed, 25 insertions, 1 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index 2f50a33448..2065f0d60d 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -41,8 +41,32 @@ case class NestedArray1(a: NestedArray2)
*/
class SQLQuerySuite extends QueryTest {
+ test("SPARK-5371: union with null and sum") {
+ val df = Seq((1, 1)).toDF("c1", "c2")
+ df.registerTempTable("table1")
+
+ val query = sql(
+ """
+ |SELECT
+ | MIN(c1),
+ | MIN(c2)
+ |FROM (
+ | SELECT
+ | SUM(c1) c1,
+ | NULL c2
+ | FROM table1
+ | UNION ALL
+ | SELECT
+ | NULL c1,
+ | SUM(c2) c2
+ | FROM table1
+ |) a
+ """.stripMargin)
+ checkAnswer(query, Row(1, 1) :: Nil)
+ }
+
test("explode nested Field") {
- Seq(NestedArray1(NestedArray2(Seq(1,2,3)))).toDF.registerTempTable("nestedArray")
+ Seq(NestedArray1(NestedArray2(Seq(1, 2, 3)))).toDF.registerTempTable("nestedArray")
checkAnswer(
sql("SELECT ints FROM nestedArray LATERAL VIEW explode(a.b) a AS ints"),
Row(1) :: Row(2) :: Row(3) :: Nil)