aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Armbrust <michael@databricks.com>2014-07-21 18:18:17 -0700
committerMichael Armbrust <michael@databricks.com>2014-07-21 18:18:17 -0700
commit511a7314037219c23e824ea5363bf7f1df55bab3 (patch)
tree23c2f201d4539d83fbc0cac802bb3416f330bee2
parenta4d60208ec7995146541451849c51670cdc56451 (diff)
downloadspark-511a7314037219c23e824ea5363bf7f1df55bab3.tar.gz
spark-511a7314037219c23e824ea5363bf7f1df55bab3.tar.bz2
spark-511a7314037219c23e824ea5363bf7f1df55bab3.zip
[SPARK-2561][SQL] Fix apply schema
We need to use the analyzed attributes otherwise we end up with a tree that will never resolve. Author: Michael Armbrust <michael@databricks.com> Closes #1470 from marmbrus/fixApplySchema and squashes the following commits: f968195 [Michael Armbrust] Use analyzed attributes when applying the schema. 4969015 [Michael Armbrust] Add test case.
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala2
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala6
2 files changed, 7 insertions, 1 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
index 993d085c75..31d27bb4f0 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/SchemaRDD.scala
@@ -430,7 +430,7 @@ class SchemaRDD(
* @group schema
*/
private def applySchema(rdd: RDD[Row]): SchemaRDD = {
- new SchemaRDD(sqlContext, SparkLogicalPlan(ExistingRdd(logicalPlan.output, rdd)))
+ new SchemaRDD(sqlContext, SparkLogicalPlan(ExistingRdd(queryExecution.analyzed.output, rdd)))
}
// =======================================================================
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
index 68dae58728..c8ea01c4e1 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DslQuerySuite.scala
@@ -33,6 +33,12 @@ class DslQuerySuite extends QueryTest {
testData.collect().toSeq)
}
+ test("repartition") {
+ checkAnswer(
+ testData.select('key).repartition(10).select('key),
+ testData.select('key).collect().toSeq)
+ }
+
test("agg") {
checkAnswer(
testData2.groupBy('a)('a, Sum('b)),