This is an automated email from the ASF dual-hosted git repository. gengliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 9f9a0a45071 [SPARK-39865][SQL][FOLLOWUP] Implement the sql() and toString() methods of `CheckOverflowInTableInsert ` 9f9a0a45071 is described below commit 9f9a0a4507154d11cb62256291e3dd42b735abe9 Author: Gengliang Wang <gengli...@apache.org> AuthorDate: Wed Aug 3 00:57:56 2022 -0700 [SPARK-39865][SQL][FOLLOWUP] Implement the sql() and toString() methods of `CheckOverflowInTableInsert ` ### What changes were proposed in this pull request? Implement the sql() and toString() methods of `CheckOverflowInTableInsert `. Both should be consistent with the child `Cast`. ### Why are the changes needed? CheckOverflowInTableInsert is just an internal expression. The SQL representation and explain() output of a table insertion plan don't need to show the expression. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT Closes #37383 from gengliangwang/toString. Authored-by: Gengliang Wang <gengli...@apache.org> Signed-off-by: Gengliang Wang <gengli...@apache.org> --- .../scala/org/apache/spark/sql/catalyst/expressions/Cast.scala | 4 ++++ .../org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala index f740ecd9dcb..37e141ab091 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala @@ -2400,4 +2400,8 @@ case class CheckOverflowInTableInsert(child: Cast, columnName: String) extends U } override def dataType: DataType = child.dataType + + override def sql: String = child.sql + + override def toString: String = child.toString } diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala index 97cbc781829..03467308d14 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuiteBase.scala @@ -1305,4 +1305,11 @@ abstract class CastSuiteBase extends SparkFunSuite with ExpressionEvalHelper { Cast(child, DecimalType.USER_DEFAULT), it) } } + + test("SPARK-39865: toString() and sql() methods of CheckOverflowInTableInsert") { + val cast = Cast(Literal(1.0), IntegerType) + val expr = CheckOverflowInTableInsert(cast, "column_1") + assert(expr.sql == cast.sql) + assert(expr.toString == cast.toString) + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org