maropu commented on a change in pull request #24158: [SPARK-26847][SQL] Pruning 
nested serializers from object serializers: MapType support
URL: https://github.com/apache/spark/pull/24158#discussion_r268031052
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/objects.scala
 ##########
 @@ -132,49 +130,74 @@ object ObjectSerializerPruning extends Rule[LogicalPlan] 
{
         fields.map(f => collectStructType(f.dataType, structs))
       case ArrayType(elementType, _) =>
         collectStructType(elementType, structs)
+      case MapType(_, valueType, _) =>
+        // Because we can't select a field from struct in key, so we skip key 
type.
+        collectStructType(valueType, structs)
       case _ =>
     }
     structs
   }
 
+  /**
+   * This method returns pruned `CreateNamedStruct` expression given an 
original `CreateNamedStruct`
+   * and a pruned `StructType`.
+   */
+  private def pruneNamedStruct(struct: CreateNamedStruct, prunedType: 
StructType) = {
+    // Filters out the pruned fields.
+    val prunedFields = struct.nameExprs.zip(struct.valExprs).filter { case 
(nameExpr, _) =>
+      val name = nameExpr.eval(EmptyRow).toString
 
 Review comment:
   Any reason to explicitly set `EmptyRow` here? Some callsites does so, but 
the other sites does not.

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


With regards,
Apache Git Services

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

Reply via email to