MaxGekk commented on code in PR #38463: URL: https://github.com/apache/spark/pull/38463#discussion_r1011505471
########## 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: It seems that would be hard to make NON_FOLDABLE_INPUT more general to cover the case. Let's introduce more specific error class for the case. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala: ########## @@ -668,10 +699,19 @@ case class UpdateFields(structExpr: Expression, fieldOps: Seq[StructFieldsOperat override def checkInputDataTypes(): TypeCheckResult = { val dataType = structExpr.dataType if (!dataType.isInstanceOf[StructType]) { - TypeCheckResult.TypeCheckFailure("struct argument should be struct type, got: " + - dataType.catalogString) + DataTypeMismatch( + errorSubClass = "UNEXPECTED_INPUT_TYPE", + messageParameters = Map( + "paramIndex" -> "1", + "requiredType" -> toSQLType(StructType), + "inputSql" -> toSQLExpr(structExpr), + "inputType" -> toSQLType(structExpr.dataType)) + ) } else if (newExprs.isEmpty) { - TypeCheckResult.TypeCheckFailure("cannot drop all fields in struct") + DataTypeMismatch( Review Comment: It is some kind of `UNEXPECTED_INPUT_TYPE`: op (drop field) + its args are not supported because they produce empty struct. I am ok w/ this particular error class. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org