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 is 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org