You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by wzhfy <gi...@git.apache.org> on 2017/07/01 09:26:49 UTC

[GitHub] spark pull request #18421: [SPARK-21213][SQL] Support collecting partition-l...

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

    https://github.com/apache/spark/pull/18421#discussion_r125152161
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/SparkSqlParser.scala ---
    @@ -91,29 +91,44 @@ class SparkSqlAstBuilder(conf: SQLConf) extends AstBuilder(conf) {
     
       /**
        * Create an [[AnalyzeTableCommand]] command or an [[AnalyzeColumnCommand]] command.
    -   * Example SQL for analyzing table :
    +   * 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 partitionSpec =
    +      if (ctx.partitionSpec != null) {
    +        val filteredSpec = visitPartitionSpec(ctx.partitionSpec).filter(x => x._2.isDefined)
    +        if (filteredSpec.isEmpty) {
    +          None
    +        } else {
    +          Some(filteredSpec.mapValues(v => v.get))
    --- End diff --
    
    `mapValues(_.get)`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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