cloud-fan commented on code in PR #36703: URL: https://github.com/apache/spark/pull/36703#discussion_r891256881
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala: ########## @@ -1792,15 +1792,16 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit override def visitCast(ctx: CastContext): Expression = withOrigin(ctx) { val rawDataType = typedVisit[DataType](ctx.dataType()) val dataType = CharVarcharUtils.replaceCharVarcharWithStringForCast(rawDataType) - val cast = ctx.name.getType match { + ctx.name.getType match { case SqlBaseParser.CAST => - Cast(expression(ctx.expression), dataType) + val cast = Cast(expression(ctx.expression), dataType) + cast.setTagValue(Cast.USER_SPECIFIED_CAST, true) + cast case SqlBaseParser.TRY_CAST => + // TRY_CAST can only be user-specified and we don't need to set the Tag. Review Comment: `USER_SPECIFIED_CAST` is a TreeNodeTag that is only used by `Cast`, we don't need to set it in `TryCast`. Let me improve the comment. -- 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