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

gurwls223 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 3edc9c23a723 [SPARK-49323][CONNECT] Move MockObserver from Spark 
Connect Server's test folder to the Server's main folder
3edc9c23a723 is described below

commit 3edc9c23a723a92c5a951cea0436529de65c640a
Author: Thang Long VU <long...@databricks.com>
AuthorDate: Wed Aug 21 20:03:05 2024 +0900

    [SPARK-49323][CONNECT] Move MockObserver from Spark Connect Server's test 
folder to the Server's main folder
    
    ### What changes were proposed in this pull request?
    
    Move class `MockObserver` from the Spark Connect Server's test folder to 
the Server's main folder, so that this class can be shaded as well, from 
`io.grpc` to `org.sparkproject.connect.grpc`.
    
    
https://github.com/apache/spark/blob/ba208b9ca99990fa329c36b28d0aa2a5f4d0a77e/project/SparkBuild.scala#L775
    
    ### Why are the changes needed?
    
    The `MockObserver` class is a mock of the `StreamObserver` class from the 
gRPC library, used for testing the process function of 
[SparkConnectPlanner](url).
    
    Currently, the [[`MockObserver`]] class is located in the test folder, 
which is not shaded by sbt-assembly, unlike the main folder.
    
    This results in a compilation error when open-source libraries call the 
`transform(spark: SparkSession, command: proto.Command)` function in 
`SparkConnectPlannerTestUtils`, which in turn calls 
`SparkConnectPlanner(executeHolder).process(command, new MockObserver())`.
    
    To resolve this, the `MockObserver` class should be moved to the main 
folder to be shaded as well.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UTs.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #47816 from longvu-db/move-mock-observer.
    
    Authored-by: Thang Long VU <long...@databricks.com>
    Signed-off-by: Hyukjin Kwon <gurwls...@apache.org>
---
 .../spark/sql/connect/planner/MockObserver.scala   | 43 ++++++++++++++++++++++
 .../planner/SparkConnectPlannerTestUtils.scala     |  9 -----
 2 files changed, 43 insertions(+), 9 deletions(-)

diff --git 
a/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/MockObserver.scala
 
b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/MockObserver.scala
new file mode 100644
index 000000000000..1519fb8a4675
--- /dev/null
+++ 
b/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/MockObserver.scala
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.connect.planner
+
+import io.grpc.stub.StreamObserver
+
+import org.apache.spark.connect.proto
+
+/*
+ * The [[MockObserver]] class is a mock of the [[StreamObserver]] class from
+ * the gRPC library, used for testing the process function of 
[[SparkConnectPlanner]].
+ *
+ * Currently, the [[MockObserver]] class is located in the test folder,
+ * which is not shaded by sbt-assembly, unlike the main folder.
+ *
+ * This results in a compilation error when open-source libraries call the
+ * [[transform(spark: SparkSession, command: proto.Command)]] function in
+ * [[SparkConnectPlannerTestUtils]], which in turn calls
+ * [[SparkConnectPlanner(executeHolder).process(command, new MockObserver())]].
+ *
+ * To resolve this, the [[MockObserver]] class should be moved to the main 
folder
+ * to be shaded as well.
+ */
+private[connect] class MockObserver extends 
StreamObserver[proto.ExecutePlanResponse] {
+  override def onNext(value: proto.ExecutePlanResponse): Unit = {}
+  override def onError(t: Throwable): Unit = {}
+  override def onCompleted(): Unit = {}
+}
diff --git 
a/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/planner/SparkConnectPlannerTestUtils.scala
 
b/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/planner/SparkConnectPlannerTestUtils.scala
index efde2fd72aeb..f700fd67d37f 100644
--- 
a/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/planner/SparkConnectPlannerTestUtils.scala
+++ 
b/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/planner/SparkConnectPlannerTestUtils.scala
@@ -17,10 +17,7 @@
 
 package org.apache.spark.sql.connect.planner
 
-import io.grpc.stub.StreamObserver
-
 import org.apache.spark.connect.proto
-import org.apache.spark.connect.proto.ExecutePlanResponse
 import org.apache.spark.sql.SparkSession
 import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
 import org.apache.spark.sql.connect.SparkConnectTestUtils
@@ -62,10 +59,4 @@ object SparkConnectPlannerTestUtils {
     executeHolder.eventsManager.status_(ExecuteStatus.Started)
     executeHolder
   }
-
-  private class MockObserver extends StreamObserver[proto.ExecutePlanResponse] 
{
-    override def onNext(value: ExecutePlanResponse): Unit = {}
-    override def onError(t: Throwable): Unit = {}
-    override def onCompleted(): Unit = {}
-  }
 }


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

Reply via email to