You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "beliefer (via GitHub)" <gi...@apache.org> on 2025/01/11 09:59:52 UTC

Re: [PR] [SPARK-50792][SQL] Format binary data as a binary literal in JDBC. [spark]

beliefer commented on code in PR #49452:
URL: https://github.com/apache/spark/pull/49452#discussion_r1911957461


##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/V2JDBCTest.scala:
##########
@@ -986,4 +986,18 @@ private[v2] trait V2JDBCTest extends SharedSparkSession with DockerIntegrationFu
   test("scan with filter push-down with date time functions") {
     testDatetime(s"$catalogAndNamespace.${caseConvert("datetime")}")
   }
+
+  test("SPARK-50792 Format binary data as a binary literal in JDBC.") {
+    withTable(s"$catalogName.test_binary_literal") {
+      // Create a table with binary column
+      val binary = "X'123456'"
+      val tableName = "test_binary_literal"
+
+      sql(s"CREATE TABLE $catalogName.$tableName (binary_col BINARY)")
+      sql(s"INSERT INTO $catalogName.$tableName VALUES ($binary)")
+
+      val select = s"SELECT * FROM $catalogName.$tableName WHERE binary_col = $binary"
+      assert(spark.sql(select).collect().length === 1, s"Binary literal test failed: $select")
+    }
+  }

Review Comment:
   Please prepare data at `tablePreparation`.



##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/V2JDBCTest.scala:
##########
@@ -986,4 +986,18 @@ private[v2] trait V2JDBCTest extends SharedSparkSession with DockerIntegrationFu
   test("scan with filter push-down with date time functions") {
     testDatetime(s"$catalogAndNamespace.${caseConvert("datetime")}")
   }
+
+  test("SPARK-50792 Format binary data as a binary literal in JDBC.") {
+    withTable(s"$catalogName.test_binary_literal") {
+      // Create a table with binary column
+      val binary = "X'123456'"
+      val tableName = "test_binary_literal"
+
+      sql(s"CREATE TABLE $catalogName.$tableName (binary_col BINARY)")
+      sql(s"INSERT INTO $catalogName.$tableName VALUES ($binary)")
+
+      val select = s"SELECT * FROM $catalogName.$tableName WHERE binary_col = $binary"
+      assert(spark.sql(select).collect().length === 1, s"Binary literal test failed: $select")
+    }
+  }

Review Comment:
   Please add the similar test case into `JDBCV2Suite`.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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