cloud-fan commented on a change in pull request #27499: [SPARK-30590][SQL] 
Untyped select API cannot take typed column expression
URL: https://github.com/apache/spark/pull/27499#discussion_r378195085
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/DatasetAggregatorSuite.scala
 ##########
 @@ -394,4 +403,21 @@ class DatasetAggregatorSuite extends QueryTest with 
SharedSparkSession {
     checkAnswer(group, Row("bob", Row(true, 3)) :: Nil)
     checkDataset(group.as[OptionBooleanIntData], OptionBooleanIntData("bob", 
Some((true, 3))))
   }
+
+  test("SPARK-30590: select multiple typed column expressions") {
+    val df = Seq((1, 2, 3, 4, 5, 6)).toDF("a", "b", "c", "d", "e", "f")
+    val fooAgg = (i: Int) => FooAgg(i).toColumn.name(s"foo_agg_$i")
+
+    val agg1 = df.select(fooAgg(1), fooAgg(2), fooAgg(3), fooAgg(4), fooAgg(5))
+    checkDataset(agg1, (3, 5, 7, 9, 11))
+
+    val agg2 = df.selectUntyped(fooAgg(1), fooAgg(2), fooAgg(3), fooAgg(4), 
fooAgg(5), fooAgg(6))
+      .asInstanceOf[Dataset[(Int, Int, Int, Int, Int, Int)]]
+    checkDataset(agg2, (3, 5, 7, 9, 11, 13))
+
+    val err = intercept[AnalysisException] {
+      df.select(fooAgg(1), fooAgg(2), fooAgg(3), fooAgg(4), fooAgg(5), 
fooAgg(6))
 
 Review comment:
   OK I see the point. If this is supported, then we can't add new typed 
`select` overloads as it breaks compatibility (the return type changes). What's 
the current behavior without your fix?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to