Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/21010#discussion_r186607122
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala
---
@@ -706,6 +706,30 @@ class StringExpressionsSuite extends SparkFunSuite
with ExpressionEvalHelper {
"15,159,339,180,002,773.2778")
checkEvaluation(FormatNumber(Literal.create(null, IntegerType),
Literal(3)), null)
assert(FormatNumber(Literal.create(null, NullType),
Literal(3)).resolved === false)
+
+ checkEvaluation(FormatNumber(Literal(12332.123456),
Literal("##############.###")), "12332.123")
+ checkEvaluation(FormatNumber(Literal(12332.123456),
Literal("##.###")), "12332.123")
+ checkEvaluation(FormatNumber(Literal(4.asInstanceOf[Byte]),
Literal("##.####")), "4")
+ checkEvaluation(FormatNumber(Literal(4.asInstanceOf[Short]),
Literal("##.####")), "4")
+ checkEvaluation(FormatNumber(Literal(4.0f), Literal("##.###")), "4")
+ checkEvaluation(FormatNumber(Literal(4), Literal("##.###")), "4")
+ checkEvaluation(FormatNumber(Literal(12831273.23481d),
+ Literal("###,###,###,###,###.###")), "12,831,273.235")
+ checkEvaluation(FormatNumber(Literal(12831273.83421d), Literal("")),
"12,831,274")
+ checkEvaluation(FormatNumber(Literal(123123324123L),
Literal("###,###,###,###,###.###")),
+ "123,123,324,123")
+ checkEvaluation(
+ FormatNumber(Literal(Decimal(123123324123L) *
Decimal(123123.21234d)),
+ Literal("###,###,###,###,###.####")),
"15,159,339,180,002,773.2778")
+ checkEvaluation(FormatNumber(Literal.create(null, IntegerType),
Literal("##.###")), null)
+ assert(FormatNumber(Literal.create(null, NullType),
Literal("##.###")).resolved === false)
+
+ checkEvaluation(FormatNumber(Literal(12332.123456),
Literal("#,###,###,###,###,###,##0")),
+ "12,332")
+ checkEvaluation(FormatNumber(
+ Literal.create(null, IntegerType), Literal.create(null, NullType)),
null)
+ checkEvaluation(FormatNumber(
+ Literal.create(null, NullType), Literal.create(null, NullType)),
null)
--- End diff --
What's for these two cases?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]