dilipbiswal commented on a change in pull request #24150: [SPARK-27209][SQL]
Split parsing of SELECT and INSERT into two top-level rules in the grammar file.
URL: https://github.com/apache/spark/pull/24150#discussion_r268374961
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -106,21 +106,37 @@ class AstBuilder(conf: SQLConf) extends
SqlBaseBaseVisitor[AnyRef] with Logging
val query = plan(ctx.queryNoWith)
// Apply CTEs
- query.optional(ctx.ctes) {
- val ctes = ctx.ctes.namedQuery.asScala.map { nCtx =>
- val namedQuery = visitNamedQuery(nCtx)
- (namedQuery.alias, namedQuery)
- }
- // Check for duplicate names.
- checkDuplicateKeys(ctes, ctx)
- With(query, ctes)
+ query.optionalMap(ctx.ctes)(withCTE)
+ }
+
+ private def withCTE(ctx: CtesContext, plan: LogicalPlan): LogicalPlan = {
+ val ctes = ctx.namedQuery.asScala.map { nCtx =>
+ val namedQuery = visitNamedQuery(nCtx)
+ (namedQuery.alias, namedQuery)
}
+ // Check for duplicate names.
+ checkDuplicateKeys(ctes, ctx)
+ With(plan, ctes)
}
override def visitQueryToDesc(ctx: QueryToDescContext): LogicalPlan =
withOrigin(ctx) {
plan(ctx.queryTerm).optionalMap(ctx.queryOrganization)(withQueryResultClauses)
}
+ override def visitQueryWithFrom(ctx: QueryWithFromContext): LogicalPlan =
withOrigin(ctx) {
+ val from = visitFromClause(ctx.fromClause)
+ validate(ctx.querySpecification.fromClause == null,
+ "Script transformation queries cannot have a FROM clause in their" +
Review comment:
@cloud-fan Thank you. will change.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]