Skip to content

Commit 0fea5a9

Browse files
committed
[SPARK-33292][SQL] Make Literal ArrayBasedMapData string representation disambiguous
1 parent cbd3fde commit 0fea5a9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ case class Literal (value: Any, dataType: DataType) extends LeafExpression {
297297
override def toString: String = value match {
298298
case null => "null"
299299
case binary: Array[Byte] => s"0x" + DatatypeConverter.printHexBinary(binary)
300+
case d: ArrayBasedMapData => s"map(${d.toString})"
300301
case other => other.toString
301302
}
302303

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralExpressionSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class LiteralExpressionSuite extends SparkFunSuite with ExpressionEvalHelper {
209209
}
210210
checkMapLiteral(Map("a" -> 1, "b" -> 2, "c" -> 3))
211211
checkMapLiteral(Map("1" -> 1.0, "2" -> 2.0, "3" -> 3.0))
212+
assert(Literal.create(Map("a" -> 1)).toString === "map(keys: [a], values: [1])")
212213
}
213214

214215
test("struct") {

0 commit comments

Comments
 (0)