cloud-fan commented on code in PR #41007: URL: https://github.com/apache/spark/pull/41007#discussion_r1198426047
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala: ########## @@ -368,7 +369,7 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef] with SQLConfHelper wit override def visitDeleteFromTable( ctx: DeleteFromTableContext): LogicalPlan = withOrigin(ctx) { - val table = createUnresolvedRelation(ctx.multipartIdentifier()) + val table = createUnresolvedRelation(ctx.relationReference()) Review Comment: We can add a new parser rule as this PR already did ``` identifierReference: : IDENTIFIER_KW LEFT_PAREN expression RIGHT_PAREN | multipartIdentifier ``` then we update the parser rules for commands one by one, for each command, we update the corresponding scala part. Taking DROP TABLE as an example, the current scala part is ``` override def visitDropTable(ctx: DropTableContext): LogicalPlan = withOrigin(ctx) { // DROP TABLE works with either a table or a temporary view. DropTable( UnresolvedIdentifier(visitMultipartIdentifier(ctx.multipartIdentifier()), allowTemp = true), ctx.EXISTS != null, ctx.PURGE != null) } ``` we can change it to ``` case class PlanWithUnresolvedIdentifier(identifierExpr: Expression, planBuilder: Seq[String] => LogicalPlan) def withIdentClause(ctx: IdentifierReferenceContext, builder: Seq[String] => LogicalPlan): LogicalPlan = { if (ctx.expression != null) { PlanWithUnresolvedIdentifier(expr(ctx.expression), builder) } else { builder.apply(visitMultipartIdentifier(ctx.multipartIdentifier())) } } override def visitDropTable(ctx: DropTableContext): LogicalPlan = withOrigin(ctx) { withIdentClause(ctx.identifierReference, ident => { DropTable( UnresolvedIdentifier(ident, allowTemp = true), ctx.EXISTS != null, ctx.PURGE != null) }) } ``` -- 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