panbingkun commented on code in PR #38463:
URL: https://github.com/apache/spark/pull/38463#discussion_r1010356813
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala:
##########
@@ -444,17 +460,32 @@ case class CreateNamedStruct(children: Seq[Expression])
extends Expression with
override def checkInputDataTypes(): TypeCheckResult = {
if (children.size % 2 != 0) {
- TypeCheckResult.TypeCheckFailure(s"$prettyName expects an even number of
arguments.")
+ DataTypeMismatch(
+ errorSubClass = "WRONG_NUM_ARGS",
+ messageParameters = Map(
+ "functionName" -> toSQLId(prettyName),
+ "expectedNum" -> "2n (n > 0)",
+ "actualNum" -> children.length.toString
+ )
+ )
} else {
val invalidNames = nameExprs.filterNot(e => e.foldable && e.dataType ==
StringType)
if (invalidNames.nonEmpty) {
- TypeCheckResult.TypeCheckFailure(
- s"Only foldable ${StringType.catalogString} expressions are allowed
to appear at odd" +
- s" position, got: ${invalidNames.mkString(",")}")
+ DataTypeMismatch(
+ errorSubClass = "CREATE_NAMED_STRUCT_WITHOUT_FOLDABLE_STRING",
Review Comment:
<img width="858" alt="image"
src="https://user-images.githubusercontent.com/15246973/199229111-f39526ba-1f5e-46b0-b8b5-6abad300674b.png">
--
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]