nija-at commented on code in PR #41807:
URL: https://github.com/apache/spark/pull/41807#discussion_r1251028952
##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/SparkSessionSuite.scala:
##########
@@ -73,4 +78,21 @@ class SparkSessionSuite extends ConnectFunSuite {
session2.close()
}
}
+
+ class CustomChannelBuilder() extends ChannelBuilder() {
+ override def createChannelBuilder(
+ host: String,
+ port: Int,
+ credentials: ChannelCredentials): ManagedChannelBuilder[_] = {
+
+ val builder = super.createChannelBuilder(host, port, credentials)
+ builder.userAgent("Custom agent")
+ builder
+ }
+ }
+
+ test("channelBuilder") {
+ val channelBuilder = new CustomChannelBuilder()
+
SparkSession.builder().remote("sc://test.it:16845").channelBuilder(channelBuilder).create()
Review Comment:
missing assertion.
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/SparkSession.scala:
##########
@@ -685,7 +693,8 @@ object SparkSession extends Logging {
* @since 3.5.0
*/
def create(): SparkSession = {
-
tryCreateSessionFromClient().getOrElse(SparkSession.this.create(builder.configuration))
+ tryCreateSessionFromClient().getOrElse(
Review Comment:
Yes it should.
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/connect/client/ChannelBuilder.scala:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.client
+
+import scala.language.existentials
+
+import io.grpc.{ChannelCredentials, Grpc, ManagedChannel,
ManagedChannelBuilder}
+
+import
org.apache.spark.sql.connect.client.SparkConnectClient.MetadataHeaderClientInterceptor
+import org.apache.spark.sql.connect.common.config.ConnectCommon
+
+class ChannelBuilder() {
Review Comment:
Add scaladoc.
(I understand it's not present consistently in the existing code base but we
should have it for all public APIs. Let's add for the ones being introduced
here)
##########
connector/connect/client/jvm/src/main/scala/org/apache/spark/sql/SparkSession.scala:
##########
@@ -628,8 +625,13 @@ object SparkSession extends Logging {
/**
* Create a new [[SparkSession]] based on the connect client
[[Configuration]].
*/
- private[sql] def create(configuration: Configuration): SparkSession = {
- new SparkSession(new SparkConnectClient(configuration), cleaner,
planIdGenerator)
+ private[sql] def create(
+ configuration: Configuration,
+ channelBuilder: Option[ChannelBuilder] = None): SparkSession = {
Review Comment:
Can channel builder be part of the `Configuration` class?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]