pan3793 commented on code in PR #52705:
URL: https://github.com/apache/spark/pull/52705#discussion_r2455205390


##########
sql/connect/client/jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc/SparkConnectDriverSuite.scala:
##########
@@ -17,18 +17,69 @@
 
 package org.apache.spark.sql.connect.client.jdbc
 
-import java.sql.DriverManager
+import java.sql.{Array => _, _}
+import java.util.Properties
 
-import org.scalatest.funsuite.AnyFunSuite // scalastyle:ignore funsuite
+import org.apache.spark.SparkBuildInfo.{spark_version => SPARK_VERSION}
+import org.apache.spark.sql.connect.client.jdbc.test.JdbcHelper
+import org.apache.spark.sql.connect.test.{ConnectFunSuite, RemoteSparkSession}
+import org.apache.spark.util.VersionUtils
 
-class SparkConnectDriverSuite extends AnyFunSuite { // scalastyle:ignore 
funsuite
+class SparkConnectDriverSuite extends ConnectFunSuite with RemoteSparkSession
+    with JdbcHelper {
 
-  // explicitly load the class to make it known to the DriverManager
-  classOf[SparkConnectDriver].getClassLoader
+  def jdbcUrl: String = s"jdbc:sc://localhost:$serverPort"
 
-  val jdbcUrl: String = s"jdbc:sc://localhost:15002"
-
-  test("test SparkConnectDriver") {
+  test("get Connection from SparkConnectDriver") {
     assert(DriverManager.getDriver(jdbcUrl).isInstanceOf[SparkConnectDriver])
+
+    val cause = intercept[SQLException] {
+      new SparkConnectDriver().connect(null, new Properties())
+    }
+    assert(cause.getMessage === "url must not be null")
+
+    withConnection { conn =>
+      assert(conn.isInstanceOf[SparkConnectConnection])
+    }
+  }
+
+  test("get DatabaseMetaData from SparkConnectConnection") {
+    withConnection { conn =>
+      val spark = conn.asInstanceOf[SparkConnectConnection].spark
+      val metadata = conn.getMetaData

Review Comment:
   Note: there nearly 200 methods defined in DatabaseMetaData interface, in 
this Initial implementation, I only implemented some essential methods which is 
no ambiguity or required by BeeLine to work. The remaining methods will be 
implemented in subsequent PRs.



##########
sql/connect/client/jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc/SparkConnectDriverSuite.scala:
##########
@@ -17,18 +17,69 @@
 
 package org.apache.spark.sql.connect.client.jdbc
 
-import java.sql.DriverManager
+import java.sql.{Array => _, _}
+import java.util.Properties
 
-import org.scalatest.funsuite.AnyFunSuite // scalastyle:ignore funsuite
+import org.apache.spark.SparkBuildInfo.{spark_version => SPARK_VERSION}
+import org.apache.spark.sql.connect.client.jdbc.test.JdbcHelper
+import org.apache.spark.sql.connect.test.{ConnectFunSuite, RemoteSparkSession}
+import org.apache.spark.util.VersionUtils
 
-class SparkConnectDriverSuite extends AnyFunSuite { // scalastyle:ignore 
funsuite
+class SparkConnectDriverSuite extends ConnectFunSuite with RemoteSparkSession
+    with JdbcHelper {
 
-  // explicitly load the class to make it known to the DriverManager
-  classOf[SparkConnectDriver].getClassLoader
+  def jdbcUrl: String = s"jdbc:sc://localhost:$serverPort"
 
-  val jdbcUrl: String = s"jdbc:sc://localhost:15002"
-
-  test("test SparkConnectDriver") {
+  test("get Connection from SparkConnectDriver") {
     assert(DriverManager.getDriver(jdbcUrl).isInstanceOf[SparkConnectDriver])
+
+    val cause = intercept[SQLException] {
+      new SparkConnectDriver().connect(null, new Properties())
+    }
+    assert(cause.getMessage === "url must not be null")
+
+    withConnection { conn =>
+      assert(conn.isInstanceOf[SparkConnectConnection])
+    }
+  }
+
+  test("get DatabaseMetaData from SparkConnectConnection") {
+    withConnection { conn =>
+      val spark = conn.asInstanceOf[SparkConnectConnection].spark
+      val metadata = conn.getMetaData

Review Comment:
   Note: there are nearly 200 methods defined in DatabaseMetaData interface, in 
this Initial implementation, I only implemented some essential methods which is 
no ambiguity or required by BeeLine to work. The remaining methods will be 
implemented in subsequent PRs.



-- 
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]

Reply via email to