cloud-fan commented on a change in pull request #23740: [SPARK-26837][SQL] 
Pruning nested fields from object serializers
URL: https://github.com/apache/spark/pull/23740#discussion_r259868104
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
 ##########
 @@ -1680,6 +1681,76 @@ class DatasetSuite extends QueryTest with 
SharedSQLContext {
     checkAnswer(ds, Seq(Row("a"), Row("b"), Row("c")))
   }
 
+
+  // This methods checks if the given DataFrame has specified struct fields in 
object
+  // serializer. The varargs parameter `structFields` is the struct fields for 
object
+  // serializers. The first `structFields` is aligned with first serializer 
and ditto
+  // for other `structFields`.
+  private def testSerializer(df: DataFrame, structFields: Seq[Seq[String]]*): 
Unit = {
+    val serializer = df.queryExecution.optimizedPlan.collect {
+      case s: SerializeFromObject => s
+    }.head
+
+    serializer.serializer.zip(structFields).foreach { case (serializer, 
fields) =>
+      val structs = serializer.collect {
+        case c: CreateNamedStruct => c
+      }
+      assert(structs.size == fields.size)
+      structs.zip(fields).foreach { case (struct, fieldNames) =>
+        assert(struct.names.map(_.toString) == fieldNames)
+      }
+    }
+  }
+
+  test("Prune nested serializers: struct") {
 
 Review comment:
   Shall we create a new `DatasetOptimizationSuite` and put these new tests 
there?

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


With regards,
Apache Git Services

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

Reply via email to