Github user mbasmanova commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18421#discussion_r130404020
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -90,30 +90,40 @@ class SparkSqlAstBuilder(conf: SQLConf) extends 
AstBuilder(conf) {
       }
     
       /**
    -   * Create an [[AnalyzeTableCommand]] command or an 
[[AnalyzeColumnCommand]] command.
    -   * Example SQL for analyzing table :
    +   * Create an [[AnalyzeTableCommand]] command, or an 
[[AnalyzePartitionCommand]]
    +   * or an [[AnalyzeColumnCommand]] command.
    +   * Example SQL for analyzing table or a set of partitions :
        * {{{
    -   *   ANALYZE TABLE table COMPUTE STATISTICS [NOSCAN];
    +   *   ANALYZE TABLE [db_name.]tablename [PARTITION (partcol1[=val1], 
partcol2[=val2], ...)]
    +   *   COMPUTE STATISTICS [NOSCAN];
        * }}}
    +   *
        * Example SQL for analyzing columns :
        * {{{
    -   *   ANALYZE TABLE table COMPUTE STATISTICS FOR COLUMNS column1, column2;
    +   *   ANALYZE TABLE [db_name.]tablename COMPUTE STATISTICS FOR COLUMNS 
column1, column2;
        * }}}
        */
       override def visitAnalyze(ctx: AnalyzeContext): LogicalPlan = 
withOrigin(ctx) {
    -    if (ctx.partitionSpec != null) {
    -      logWarning(s"Partition specification is ignored: 
${ctx.partitionSpec.getText}")
    +    if (ctx.identifier != null &&
    +        ctx.identifier.getText.toLowerCase(Locale.ROOT) != "noscan") {
    +      throw new ParseException(s"Expected `NOSCAN` instead of 
`${ctx.identifier.getText}`", ctx)
         }
    -    if (ctx.identifier != null) {
    -      if (ctx.identifier.getText.toLowerCase(Locale.ROOT) != "noscan") {
    -        throw new ParseException(s"Expected `NOSCAN` instead of 
`${ctx.identifier.getText}`", ctx)
    +
    +    val table = visitTableIdentifier(ctx.tableIdentifier)
    +    if (ctx.identifierSeq() == null) {
    +      if (ctx.partitionSpec != null) {
    +        AnalyzePartitionCommand(table, 
visitPartitionSpec(ctx.partitionSpec),
    +          noscan = ctx.identifier != null)
    +      } else {
    +        AnalyzeTableCommand(table, noscan = ctx.identifier != null)
           }
    -      AnalyzeTableCommand(visitTableIdentifier(ctx.tableIdentifier))
    -    } else if (ctx.identifierSeq() == null) {
    -      AnalyzeTableCommand(visitTableIdentifier(ctx.tableIdentifier), 
noscan = false)
         } else {
    +      if (ctx.partitionSpec != null) {
    +        logWarning("Partition specification is ignored when collecting 
column statistics: " +
    +          ctx.partitionSpec.getText)
    --- End diff --
    
    This is the existing behavoir. ANALYZE TABLE command simply ignores 
PARTITION clause. This PR is adding support for PARTITION clause for COMPUTE 
STATISTICS, but keeps COMPUTE STATISTICS FOR COLUMNS as is. I'm planning to add 
partition support to FOR COLUMN In a follow-up PR.
    
    Changing this code to throw an exception in this PR will *break* existing 
uses if folks are relying on a WARN.
    
    Would it be OK to keep this functionality unchanged in the PR?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to