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

    https://github.com/apache/spark/pull/14207#discussion_r71083334
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala ---
    @@ -351,6 +353,44 @@ class CatalogImpl(sparkSession: SparkSession) extends 
Catalog {
       }
     
       /**
    +   * Refresh the inferred schema stored in the external catalog for data 
source tables.
    +   */
    +  private def refreshInferredSchema(tableIdent: TableIdentifier): Unit = {
    +    val table = sessionCatalog.getTableMetadataOption(tableIdent)
    +    table.foreach { tableDesc =>
    +      if (DDLUtils.isDatasourceTable(tableDesc) && 
DDLUtils.isSchemaInferred(tableDesc)) {
    +        val partitionColumns = 
DDLUtils.getPartitionColumnsFromTableProperties(tableDesc)
    +        val bucketSpec = 
DDLUtils.getBucketSpecFromTableProperties(tableDesc)
    +        val dataSource =
    +          DataSource(
    +            sparkSession,
    +            userSpecifiedSchema = None,
    +            partitionColumns = partitionColumns,
    +            bucketSpec = bucketSpec,
    +            className = 
tableDesc.properties(CreateDataSourceTableUtils.DATASOURCE_PROVIDER),
    +            options = tableDesc.storage.serdeProperties)
    +            .resolveRelation().asInstanceOf[HadoopFsRelation]
    +
    +        val schemaProperties = new mutable.HashMap[String, String]
    +        CreateDataSourceTableUtils.saveSchema(
    +          sparkSession, dataSource.schema, 
dataSource.partitionSchema.fieldNames, schemaProperties)
    +
    +        val tablePropertiesWithoutSchema = tableDesc.properties.filterKeys 
{ k =>
    +          // Keep the properties that are not for schema or partition 
columns
    +          k != CreateDataSourceTableUtils.DATASOURCE_SCHEMA_NUMPARTS &&
    --- End diff --
    
    It's hard to know what the code's doing inside `filterKeys` -- consider 
creating a predicate function with a proper name.


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