spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yhuai <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-14127][SQL] "DESC <table>": Extracts sc...
Date Tue, 10 May 2016 15:59:24 GMT
Github user yhuai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13025#discussion_r62699825
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
    @@ -489,9 +486,83 @@ private[sql] object DDLUtils {
           case _ =>
         })
       }
    +
       def isTablePartitioned(table: CatalogTable): Boolean = {
    -    table.partitionColumns.size > 0 ||
    +    table.partitionColumns.nonEmpty ||
           table.properties.contains("spark.sql.sources.schema.numPartCols")
       }
    -}
     
    +  def getSchemaFromTableProperties(metadata: CatalogTable): Option[StructType] = {
    +    getSchemaFromTableProperties(metadata.properties)
    +  }
    +
    +  // A persisted data source table may not store its schema in the catalog. In this case,
its schema
    +  // will be inferred at runtime when the table is referenced.
    +  def getSchemaFromTableProperties(props: Map[String, String]): Option[StructType] =
{
    +    require(isDatasourceTable(props))
    +
    +    val schemaParts = for {
    +      numParts <- props.get("spark.sql.sources.schema.numParts").toSeq
    +      index <- 0 until numParts.toInt
    +    } yield props.getOrElse(
    +      s"spark.sql.sources.schema.part.$index",
    +      throw new AnalysisException(
    +        s"Corrupted schema in catalog: $numParts parts expected, but part $index is missing."
    +      )
    +    )
    +
    +    if (schemaParts.isEmpty) {
    +      None
    +    } else {
    +      Some(DataType.fromJson(schemaParts.mkString).asInstanceOf[StructType])
    +    }
    +  }
    --- End diff --
    
    I will make a commit to handle `spark.sql.sources.schema`. 


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


Mime
View raw message