shivadarshan-devadiga commented on code in PR #60750:
URL: https://github.com/apache/spark/pull/60750#discussion_r4642170943
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ApplyCharTypePaddingHelper.scala:
##########
@@ -163,33 +171,29 @@ object ApplyCharTypePaddingHelper {
private def padAttrLitCmp(
expr: Expression,
- metadata: Metadata,
+ c: CharType,
padCharCol: Boolean,
lit: Expression): Option[Seq[Expression]] = {
if (expr.dataType.isInstanceOf[StringType]) {
- CharVarcharUtils.getRawType(metadata).flatMap {
- case c: CharType =>
- val str = lit.eval().asInstanceOf[UTF8String]
- if (str == null) {
- None
+ val str = lit.eval().asInstanceOf[UTF8String]
Review Comment:
Fixed. The constant is evaluated with `tryEvalString`, and a comparison
whose constant fails to evaluate is left unpadded, so the failure only surfaces
if the branch runs, as with `ConstantFolding.tryFold`. For `IN`, the comparison
is left unchanged if any element fails. This also covers top-level CHAR
columns, which already went through this evaluation. `IF(false, s.c = CAST(1 /
0 AS STRING), true)` and the `IN` variant return true under ANSI mode in
`SPARK-61970: comparisons with a struct field keep constants that fail`.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]