spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cloud-fan <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-11277] [SQL] sort_array throws exceptio...
Date Tue, 27 Oct 2015 00:38:44 GMT
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9247#discussion_r43073001
  
    --- 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 --
    
    Why get struct fields here?
    Can we test `checkEvaluation(new SortArray(arrayStruct), Seq(create_row(1), create_row(2)))`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message