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

    https://github.com/apache/spark/pull/7154#discussion_r35286721
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
    @@ -345,14 +345,23 @@ private[sql] class ParquetRelation2(
         // Schema of the whole table, including partition columns.
         var schema: StructType = _
     
    +    // Cached leaves
    +    val cachedLeaves: mutable.Map[Path, FileStatus] = new 
mutable.HashMap[Path, FileStatus]()
    +
         /**
          * Refreshes `FileStatus`es, footers, partition spec, and table schema.
          */
         def refresh(): Unit = {
           // Lists `FileStatus`es of all leaf nodes (files) under all base 
directories.
    +      // We only care about new FileStatus and updated FileStatus.
           val leaves = cachedLeafStatuses().filter { f =>
    -        isSummaryFile(f.getPath) ||
    -          !(f.getPath.getName.startsWith("_") || 
f.getPath.getName.startsWith("."))
    +        (isSummaryFile(f.getPath) ||
    +          !(f.getPath.getName.startsWith("_") || 
f.getPath.getName.startsWith("."))) &&
    +          (!cachedLeaves.contains(f.getPath) ||
    +            cachedLeaves(f.getPath).getModificationTime < 
f.getModificationTime)
    +      }.map { f =>
    +        cachedLeaves += (f.getPath -> f)
    +        f
    --- End diff --
    
    Hmm, I am thinking, if we only read the footers of the updated and newly 
added files, the merged schema may be incorrect? For the removed files, it is 
the same situation. If we don't re-merge all footers' schema, the schema should 
not be correct.
    
    So this pr should check if we need to re-read all footers and merge schema 
based on whether the `FileStatus`es are updated or not.
    
    



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to