@@ -813,6 +813,19 @@ class DataFrameAggregateSuite extends QueryTest with SharedSQLContext {
813813 Row (null ) :: Nil
814814 )
815815
816+ // structs as ordering value.
817+ checkAnswer(
818+ sql(" select max_by(x, y) FROM VALUES (('a', (10, 20))), (('b', (10, 50))), " +
819+ " (('c', (10, 60))) AS tab(x, y)" ),
820+ Row (" c" ) :: Nil
821+ )
822+
823+ checkAnswer(
824+ sql(" select max_by(x, y) FROM VALUES (('a', (10, 20))), (('b', (10, 50))), " +
825+ " (('c', null)) AS tab(x, y)" ),
826+ Row (" b" ) :: Nil
827+ )
828+
816829 withTempView(" tempView" ) {
817830 val dfWithMap = Seq ((0 , " a" ), (1 , " b" ), (2 , " c" ))
818831 .toDF(" x" , " y" )
@@ -856,6 +869,19 @@ class DataFrameAggregateSuite extends QueryTest with SharedSQLContext {
856869 Row (null ) :: Nil
857870 )
858871
872+ // structs as ordering value.
873+ checkAnswer(
874+ sql(" select min_by(x, y) FROM VALUES (('a', (10, 20))), (('b', (10, 50))), " +
875+ " (('c', (10, 60))) AS tab(x, y)" ),
876+ Row (" a" ) :: Nil
877+ )
878+
879+ checkAnswer(
880+ sql(" select min_by(x, y) FROM VALUES (('a', null)), (('b', (10, 50))), " +
881+ " (('c', (10, 60))) AS tab(x, y)" ),
882+ Row (" b" ) :: Nil
883+ )
884+
859885 withTempView(" tempView" ) {
860886 val dfWithMap = Seq ((0 , " a" ), (1 , " b" ), (2 , " c" ))
861887 .toDF(" x" , " y" )
0 commit comments