sunxiaoguang commented on code in PR #49452:
URL: https://github.com/apache/spark/pull/49452#discussion_r1913214270
##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/OracleDialect.scala:
##########
@@ -61,6 +61,34 @@ private case class OracleDialect() extends JdbcDialect with
SQLConfHelper with N
} else {
super.visitAggregateFunction(funcName, isDistinct, inputs)
}
+
+ private def compareBlob(lhs: Expression, operator: String, rhs:
Expression): String = {
+ val l = inputToSQL(lhs)
+ val r = inputToSQL(rhs)
+ val op = if (operator == "<=>") "=" else operator
+ val compare = s"DBMS_LOB.COMPARE($l, $r) $op 0"
+ if (operator == "<=>") {
+ s"(($l IS NOT NULL AND $r IS NOT NULL AND $compare) OR ($l IS NULL AND
$r IS NULL))"
+ } else {
+ compare
+ }
+ }
+
+ override def build(expr: Expression): String = expr match {
Review Comment:
All tests passed, but downloading report failed. We can rerun the whole test
again to clear all the checks, but it takes quite some time to finish.
https://github.com/sunxiaoguang/spark/actions/runs/12744731853
##########
connector/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/v2/V2JDBCTest.scala:
##########
@@ -986,4 +986,23 @@ 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.") {
+ val tableName = s"$catalogName.test_binary_literal"
+ withTable(tableName) {
+ // Unfornately, Oracle can only compare two BLOBs with a special
function dbms_lob.compare
+ // The V2ExpressionSQLBuilder can not support rewriting the '=' operator.
+ // We don't test binary data on Oracle and do not support binary data on
Oracle.
+ if (!this.isInstanceOf[OracleIntegrationSuite]) {
Review Comment:
All tests passed, but downloading report failed. We can rerun the whole test
again to clear all the checks, but it takes quite some time to finish.
https://github.com/sunxiaoguang/spark/actions/runs/12744731853
##########
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:
All tests passed, but downloading report failed. We can rerun the whole test
again to clear all the checks, but it takes quite some time to finish.
https://github.com/sunxiaoguang/spark/actions/runs/12744731853
--
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]