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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/expressions/expressions.scala:
##########
@@ -388,12 +388,13 @@ private[sql] object HoursTransform {
 }
 
 private[sql] final case class LiteralValue[T](value: T, dataType: DataType) 
extends Literal[T] {
-  override def toString: String = {
-    if (dataType.isInstanceOf[StringType]) {
-      s"'${StringUtils.replace(s"$value", "'", "''")}'"
-    } else {
-      s"$value"
-    }
+  override def toString: String = dataType match {
+    case StringType => s"'${StringUtils.replace(s"$value", "'", "''")}'"
+    case BinaryType =>
+      assert(value.isInstanceOf[Array[Byte]])
+      val bytes = value.asInstanceOf[Array[Byte]]
+      bytes.map("%02X".format(_)).mkString("X'", "", "'")

Review Comment:
   Spark SQL already parsed the format `X'123456'`.
   
   The binary literal show the format `0x123456`.
   ```
     override def toString: String = value match {
       case null => "null"
       case binary: Array[Byte] => "0x" + ApacheHex.encodeHexString(binary, 
false)
   ```
   
   Which one is the better?



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