srielau commented on code in PR #58130:
URL: https://github.com/apache/spark/pull/58130#discussion_r3846868109


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -2706,11 +2706,11 @@ case class Substring(str: Expression, pos: Expression, 
len: Expression)
 case class Right(str: Expression, len: Expression) extends RuntimeReplaceable
   with ImplicitCastInputTypes with BinaryLike[Expression] {
 
-  // Type the literal branches after R1: Substring returns plain STRING for a 
CHAR(n)/VARCHAR(n)
-  // input, so deriving the literals from str.dataType would leave the If with 
branches of
-  // different types. CheckAnalysis does not see inside a RuntimeReplaceable's 
replacement, so
-  // that mismatch would surface later as COMPLEX_EXPRESSION_UNSUPPORTED_INPUT.
-  private lazy val resultType: DataType = 
StringHelper.transformingStringResultType(str.dataType)
+  // Type the literal branches after ImplicitTypeCasts promotes CHAR/VARCHAR 
to STRING.
+  // Substring then returns STRING, so the If branches match. CheckAnalysis 
does not see inside

Review Comment:
   Addressed in de3f84f8464. Removed the inaccurate CheckAnalysis / 
COMPLEX_EXPRESSION_UNSUPPORTED_INPUT claim and kept only the explanation that 
the literal branches must use the promoted result type.



##########
sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala:
##########
@@ -1794,14 +1848,14 @@ class BasicCharVarcharTestSuite extends 
SharedSparkSession {
     // silently lost: the HybridAnalyzer compares output schema and normalized 
plan across the

Review Comment:
   Addressed in de3f84f8464. The matrix now routes every SELECT through a local 
helper that parses it, applies a fresh ResolverGuard, and fails on any 
unsupported reason before executing the query. The CREATE TABLE and INSERT 
setup statements use spark.sql directly. The targeted test passes.



-- 
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]

Reply via email to