Skip to content

Commit

Permalink
Do not support binary literal on Oracle
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoguang Sun <[email protected]>
  • Loading branch information
sunxiaoguang committed Jan 11, 2025
1 parent 09022ab commit 8ddfcc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -990,14 +990,19 @@ private[v2] trait V2JDBCTest extends SharedSparkSession with DockerIntegrationFu
test("SPARK-50792 Format binary data as a binary literal in JDBC.") {
val tableName = s"$catalogName.test_binary_literal"
withTable(tableName) {
// Create a table with binary column
val binary = "X'123456'"

sql(s"CREATE TABLE $tableName (binary_col BINARY)")
sql(s"INSERT INTO $tableName VALUES ($binary)")

val select = s"SELECT * FROM $tableName WHERE binary_col = $binary"
assert(spark.sql(select).collect().length === 1, s"Binary literal test failed: $select")
// 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]) {
// Create a table with binary column
val binary = "X'123456'"

sql(s"CREATE TABLE $tableName (binary_col BINARY)")
sql(s"INSERT INTO $tableName VALUES ($binary)")

val select = s"SELECT * FROM $tableName WHERE binary_col = $binary"
assert(spark.sql(select).collect().length === 1, s"Binary literal test failed: $select")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ private case class OracleDialect() extends JdbcDialect with SQLConfHelper with N
case timestampValue: Timestamp => "{ts '" + timestampValue + "'}"
case dateValue: Date => "{d '" + dateValue + "'}"
case arrayValue: Array[Any] => arrayValue.map(compileValue).mkString(", ")
case binaryValue: Array[Byte] =>
binaryValue.map("%02X".format(_)).mkString("HEXTORAW('", "", "')")
case _ => value
}

Expand Down

0 comments on commit 8ddfcc2

Please sign in to comment.