Skip to content

Commit

Permalink
[SPARK-39865][SQL][FOLLOWUP] Implement the sql() and toString() metho…
Browse files Browse the repository at this point in the history
…ds 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 apache#37383 from gengliangwang/toString.

Authored-by: Gengliang Wang <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
  • Loading branch information
gengliangwang committed Aug 3, 2022
1 parent 5335c78 commit 9f9a0a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 9f9a0a4

Please sign in to comment.