zsxwing commented on a change in pull request #34901:
URL: https://github.com/apache/spark/pull/34901#discussion_r768931964
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
##########
@@ -932,7 +932,19 @@ class ColumnExpressionSuite extends QueryTest with
SharedSparkSession {
testData2.collect().toSeq.map(r => Row(r.getInt(0) ^ r.getInt(1) ^ 39)))
}
+ test("SPARK-37646: lit") {
+ assert(lit($"foo") == $"foo")
+ assert(lit('foo) == $"foo")
+ assert(lit(1) == Column(Literal(1)))
+ assert(lit(null) == Column(Literal(null, NullType)))
+ }
+
test("typedLit") {
+ assert(typedLit($"foo") == $"foo")
+ assert(typedLit('foo) == $"foo")
+ assert(typedLit(1) == Column(Literal(1)))
+ assert(typedLit[String](null) == Column(Literal(null, StringType)))
Review comment:
I was trying to switch the order in `Literal.create` like this
```
def create[T : TypeTag](v: T): Literal =
Try {
Literal(v)
}.getOrElse {
Try {
val ScalaReflection.Schema(dataType, _) =
ScalaReflection.schemaFor[T]
val convert =
CatalystTypeConverters.createToCatalystConverter(dataType)
Literal(convert(v), dataType)
}.getOrElse {
Literal(v)
}
}
```
and then realized this would break this use case. So just added this test to
ensure we won't make such change in future.
--
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]