cloud-fan commented on a change in pull request #28572: URL: https://github.com/apache/spark/pull/28572#discussion_r427275688
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ########## @@ -3071,15 +3071,31 @@ class Analyzer( case p => p transformExpressions { case u @ UpCast(child, _, _) if !child.resolved => u - case UpCast(child, dt: AtomicType, _) + case UpCast(_, target, _) if target != DecimalType && !target.isInstanceOf[DataType] => + throw new AnalysisException( + s"UpCast only support DecimalType as AbstractDataType yet, but got: $target") + + case UpCast(child, target, walkedTypePath) if target == DecimalType + && child.dataType.isInstanceOf[DecimalType] => + assert(walkedTypePath.nonEmpty, + "object DecimalType should only be used inside ExpressionEncoder") + // SPARK-31750: for the case where data type is explicitly known, e.g, spark.read Review comment: nit: ``` SPARK-31750: if we want to upcast to the general decimal type, and the `child` is already decimal type, we can remove the `Upcast` and accept any precision/scale. This can happen for cases like `spark.read.parquet("/tmp/file").as[BigDecimal]`. ``` ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org