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

    https://github.com/apache/spark/pull/9247#discussion_r43074419
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CollectionFunctionsSuite.scala
 ---
    @@ -64,6 +65,21 @@ class CollectionFunctionsSuite extends SparkFunSuite 
with ExpressionEvalHelper {
         checkEvaluation(new SortArray(a3, Literal(false)), Seq("b", "a", null))
     
         checkEvaluation(Literal.create(null, ArrayType(StringType)), null)
    +    checkEvaluation(new SortArray(a4), Seq(null, null))
    +
    +    val typeAS = ArrayType(StructType(StructField("a", IntegerType) :: 
Nil))
    +    val arrayStruct = Literal.create(Seq(create_row(2), create_row(1)), 
typeAS)
    +    val sorted = new SortArray(arrayStruct)
    +
    +    def getArrayStructFields(expr: Expression, fieldName: String): 
GetArrayStructFields = {
    +      expr.dataType match {
    +        case ArrayType(StructType(fields), containsNull) =>
    +          val field = fields.find(_.name == fieldName).get
    +          GetArrayStructFields(expr, field, fields.indexOf(field), 
fields.length, containsNull)
    +      }
    +    }
    +
    +    checkEvaluation(getArrayStructFields(sorted, "a"), Seq(1, 2))
    --- End diff --
    
    I was just trying to find a way to compare the results. Your approach is 
much simpler. I have updated the test case based on your comment. Thank you for 
your comment! 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to