Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16422#discussion_r94101475
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -586,6 +587,122 @@ case class DescribeTableCommand(
       }
     }
     
    +/**
    + * Command that looks like
    + * {{{
    + *   DESCRIBE [EXTENDED|FORMATTED] table_name column_name;
    + * }}}
    + */
    +case class DescribeColumnCommand(
    +    table: TableIdentifier,
    +    column: String,
    +    isExtended: Boolean,
    +    isFormatted: Boolean)
    +  extends RunnableCommand {
    +
    +  override val output: Seq[Attribute] =
    +    // Column names are based on Hive.
    +    if (isFormatted) {
    +      Seq(
    +        AttributeReference("col_name", StringType, nullable = false,
    +          new MetadataBuilder().putString("comment", "name of the 
column").build())(),
    +        AttributeReference("data_type", StringType, nullable = false,
    +          new MetadataBuilder().putString("comment", "data type of the 
column").build())(),
    +        AttributeReference("min", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "min value of the 
column").build())(),
    +        AttributeReference("max", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "max value of the 
column").build())(),
    +        AttributeReference("num_nulls", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "number of nulls of 
the column").build())(),
    +        AttributeReference("distinct_count", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "distinct count of 
the column").build())(),
    +        AttributeReference("avg_col_len", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment",
    +            "average length of the values of the column").build())(),
    +        AttributeReference("max_col_len", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment",
    +            "max length of the values of the column").build())(),
    +        AttributeReference("comment", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "comment of the 
column").build())())
    +    } else {
    +      Seq(
    +        AttributeReference("col_name", StringType, nullable = false,
    +          new MetadataBuilder().putString("comment", "name of the 
column").build())(),
    +        AttributeReference("data_type", StringType, nullable = false,
    +          new MetadataBuilder().putString("comment", "data type of the 
column").build())(),
    +        AttributeReference("comment", StringType, nullable = true,
    +          new MetadataBuilder().putString("comment", "comment of the 
column").build())())
    +    }
    +
    +  override def run(sparkSession: SparkSession): Seq[Row] = {
    +    val result = new ArrayBuffer[Row]
    --- End diff --
    
    why we create an `ArrayBuffer`? Doesn't it always return a single row?


---
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