ulysses-you commented on a change in pull request #30923:
URL: https://github.com/apache/spark/pull/30923#discussion_r549242295



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -215,6 +215,10 @@ trait CheckAnalysis extends PredicateHelper with 
LookupCatalog {
           case s: SubqueryExpression =>
             checkSubqueryExpression(operator, s)
             s
+
+          case e: ExpressionWithRandomSeed if !e.seedExpression.foldable =>
+            failAnalysis(
+              s"Input argument to ${e.prettyName} must be an integer, long or 
null literal.")

Review comment:
       Through the `ExpectsInputTypes` and  failed if not passed 
`checkInputDataTypes`.
   e.g., `select rand(1.0)`
   ```
   Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot 
resolve 'rand(1.0BD)' due to data type mismatch: argument 1 requires (int or 
bigint) type, however, '1.0BD' is of decimal(2,1) type.; line 1 pos 7;
   'Project [unresolvedalias(rand(1.0), None)]
   +- OneRowRelation
   
        at 
org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
        at 
org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$$nestedInanonfun$checkAnalysis$1$2.applyOrElse(CheckAnalysis.scala:149)
        at 
org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$$nestedInanonfun$checkAnalysis$1$2.applyOrElse(CheckAnalysis.scala:140)
   ```




----------------------------------------------------------------
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]

Reply via email to