You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ya...@apache.org on 2023/06/07 13:03:10 UTC

[spark] branch master updated: [SPARK-43984][SQL][PROTOBUF] Change to use `foreach` when `map` doesn't produce results

This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 4ffa2722d13 [SPARK-43984][SQL][PROTOBUF] Change to use `foreach` when `map` doesn't produce results
4ffa2722d13 is described below

commit 4ffa2722d13593e46ef1c8fd59a20c439a535f61
Author: yangjie01 <ya...@baidu.com>
AuthorDate: Wed Jun 7 21:02:54 2023 +0800

    [SPARK-43984][SQL][PROTOBUF] Change to use `foreach` when `map` doesn't produce results
    
    ### What changes were proposed in this pull request?
    Similar as https://github.com/apache/spark/pull/36720, this pr change to use `foreach` when `map` doesn't produce results in Spark code,   these are new cases after Spark 3.4.
    
    ### Why are the changes needed?
    Use appropriate api.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    Pass Github Actions.
    
    Closes #41482 from LuciferYang/SPARK-43984.
    
    Authored-by: yangjie01 <ya...@baidu.com>
    Signed-off-by: yangjie01 <ya...@baidu.com>
---
 .../main/scala/org/apache/spark/sql/protobuf/ProtobufSerializer.scala | 2 +-
 sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufSerializer.scala b/connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufSerializer.scala
index b11284d1f28..611b753d024 100644
--- a/connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufSerializer.scala
+++ b/connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufSerializer.scala
@@ -173,7 +173,7 @@ private[sql] class ProtobufSerializer(
       case (MapType(kt, vt, valueContainsNull), MESSAGE) =>
         var keyField: FieldDescriptor = null
         var valueField: FieldDescriptor = null
-        fieldDescriptor.getMessageType.getFields.asScala.map { field =>
+        fieldDescriptor.getMessageType.getFields.asScala.foreach { field =>
           field.getName match {
             case "key" =>
               keyField = field
diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
index 0f689ea975d..01684f52ab8 100644
--- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
+++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
@@ -63,7 +63,7 @@ private[hive] case class HiveSimpleUDF(
 
   // TODO: Finish input output types.
   override def eval(input: InternalRow): Any = {
-    children.zipWithIndex.map {
+    children.zipWithIndex.foreach {
       case (child, idx) => evaluator.setArg(idx, child.eval(input))
     }
     evaluator.evaluate()
@@ -135,7 +135,7 @@ private[hive] case class HiveGenericUDF(
   private lazy val evaluator = new HiveGenericUDFEvaluator(funcWrapper, children)
 
   override def eval(input: InternalRow): Any = {
-    children.zipWithIndex.map {
+    children.zipWithIndex.foreach {
       case (child, idx) => evaluator.setArg(idx, child.eval(input))
     }
     evaluator.evaluate()


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