MaxGekk commented on code in PR #38727:
URL: https://github.com/apache/spark/pull/38727#discussion_r1027239674
##########
sql/core/src/test/resources/sql-tests/results/ansi/string-functions.sql.out:
##########
@@ -1597,3 +1597,20 @@ org.apache.spark.sql.AnalysisException
"invalidValue" : "invalidformat"
}
}
+
+
+-- !query
+SELECT to_binary(col1, col2) from values ('abc', 'utf-8') as data(col1, col2)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+The 'format' parameter of function 'to_binary' needs to be a string literal.;
line 1 pos 7
Review Comment:
When you move the exception from constructor, you should see
`AnalysisException` w/ an error class.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TryEval.scala:
##########
@@ -227,7 +228,8 @@ case class TryToBinary(
def this(expr: Expression, formatExpression: Expression) =
this(expr, Some(formatExpression),
- TryEval(ToBinary(expr, Some(formatExpression), nullOnInvalidFormat =
true)))
+ TryEval(ToBinary(expr, Some(TryToBinary.checkFormat(formatExpression)),
Review Comment:
Could you perform the check in `checkInputDataTypes()` as we do that in
other expression, please.
BTW, exceptions from expressions constructors are wrapped by
`AnalysisException` additionally which is not convenient to users.
--
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]