Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22316#discussion_r214722485
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/DataFramePivotSuite.scala ---
    @@ -308,4 +308,27 @@ class DataFramePivotSuite extends QueryTest with 
SharedSQLContext {
     
         assert(exception.getMessage.contains("aggregate functions are not 
allowed"))
       }
    +
    +  test("pivoting column list with values") {
    +    val expected = Row(2012, 10000.0, null) :: Row(2013, 48000.0, 30000.0) 
:: Nil
    +    val df = trainingSales
    +      .groupBy($"sales.year")
    +      .pivot(struct(lower($"sales.course"), $"training"), Seq(
    +        struct(lit("dotnet"), lit("Experts")),
    +        struct(lit("java"), lit("Dummies")))
    +      ).agg(sum($"sales.earnings"))
    +
    +    checkAnswer(df, expected)
    +  }
    +
    +  test("pivoting column list") {
    +    val exception = intercept[RuntimeException] {
    +      trainingSales
    +        .groupBy($"sales.year")
    +        .pivot(struct(lower($"sales.course"), $"training"))
    +        .agg(sum($"sales.earnings"))
    +        .collect()
    --- End diff --
    
    My changes don't throw the exception. It is thrown in the collect() : 
https://github.com/apache/spark/blob/41c2227a2318029709553a588e44dee28f106350/sql/core/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala#L385
    
    @maropu Do you propose to catch `RuntimeException` and replace it by 
`AnalysisException`?


---

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

Reply via email to