[ https://issues.apache.org/jira/browse/SPARK-31750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17110367#comment-17110367 ]
Apache Spark commented on SPARK-31750: -------------------------------------- User 'Ngone51' has created a pull request for this issue: https://github.com/apache/spark/pull/28572 > Eliminate UpCast if child's dataType is DecimalType > --------------------------------------------------- > > Key: SPARK-31750 > URL: https://issues.apache.org/jira/browse/SPARK-31750 > Project: Spark > Issue Type: Improvement > Components: SQL > Affects Versions: 3.1.0 > Reporter: wuyi > Priority: Major > > > {code:java} > sql("select cast(11111111111111111111111111111111111111 as decimal(38, 0)) as > d") > .write.mode("overwrite") > .parquet(f.getAbsolutePath) > spark.read.parquet(f.getAbsolutePath).as[BigDecimal] > {code} > {code:java} > [info] org.apache.spark.sql.AnalysisException: Cannot up cast `d` from > decimal(38,0) to decimal(38,18). > [info] The type path of the target object is: > [info] - root class: "scala.math.BigDecimal" > [info] You can either add an explicit cast to the input data or choose a > higher precision type of the field in the target object; > [info] at > org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveUpCast$.org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveUpCast$$fail(Analyzer.scala:3060) > [info] at > org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveUpCast$$anonfun$apply$33$$anonfun$applyOrElse$174.applyOrElse(Analyzer.scala:3087) > [info] at > org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveUpCast$$anonfun$apply$33$$anonfun$applyOrElse$174.applyOrElse(Analyzer.scala:3071) > [info] at > org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$1(TreeNode.scala:309) > [info] at > org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:72) > [info] at > org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:309) > [info] at > org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$transformDown$3(TreeNode.scala:314) > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org