maropu commented on a change in pull request #30923:
URL: https://github.com/apache/spark/pull/30923#discussion_r548818404
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/randomExpressions.scala
##########
@@ -49,8 +48,6 @@ abstract class RDG extends UnaryExpression with
ExpectsInputTypes with Stateful
@transient protected lazy val seed: Long = seedExpression match {
case Literal(s, IntegerType) => s.asInstanceOf[Int]
case Literal(s, LongType) => s.asInstanceOf[Long]
Review comment:
Ur, we might need to update the two entries above like this;
```
case e if e.dataType == IntegerType => e.eval().asInstanceOf[Int]
case e if e.dataType == LongType => e.eval().asInstanceOf[Long]
```
Otherwise, we can hit a unmatch exception when excluding `ConstantFolding`
and `ReorderAssociativeOperator`?
```
// v3.0.1
:$./bin/spark-shell --conf
spark.sql.optimizer.excludedRules=org.apache.spark.sql.catalyst.optimizer.ConstantFolding,org.apache.spark.sql.catalyst.optimizer.ReorderAssociativeOperator
scala> sql("select rand(1 + 2)").show()
org.apache.spark.sql.AnalysisException: Input argument to rand must be an
integer, long or null literal.;
at
org.apache.spark.sql.catalyst.expressions.RDG.seed$lzycompute(randomExpressions.scala:49)
at
org.apache.spark.sql.catalyst.expressions.RDG.seed(randomExpressions.scala:46)
at
org.apache.spark.sql.catalyst.expressions.Rand.doGenCode(randomExpressions.scala:98)
at
org.apache.spark.sql.catalyst.expressions.Expression.$anonfun$genCode$3(Expression.scala:146)
at scala.Option.getOrElse(Option.scala:189)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]