turboFei commented on issue #25863: [WIP][SPARK-29037][CORE][SQL] For static 
partition overwrite, spark may give duplicate result.
URL: https://github.com/apache/spark/pull/25863#issuecomment-533975028
 
 
   > > After commitJob we just need invoke mergePaths(fs, outputPath, 
tablePath) and clean up stagingDir.
   > 
   > How expensive is it? Previously the output path is table path directly, 
right?
   
   I have checked the code of mergePaths method in FileOutputCommitter.
   When `commitJob`, `mergePaths` is invoked to merge the files under 
taskAttemptPaths.
   Its args is `fs(fileSystem)`,` from` and  `to`.
   If `to` is null, it just need  rename. 
   
   
   For example, for the sql `insert overwrite table ta partition(p1=1,p2=2) 
select ...`.
   After commitJob to stagingDir, it just need rename 
`stagingDir/appId/staticPrefixPath/p1=1/p2=2` to `tablePath/p1=1/p2=2`, because 
`tablePath/p1=1/p2=2` has been dropped.
   
   For the sql `insert overwrite table ta select ...` (ta is a partitioned 
table).
   After commitJob to stagingDir, there will be many partitions under 
`stagingDir/appId/staticPrefixPath/`, such as `p1=v1`, `p2=v2`, `pn=vn`.
   And we just need to rename these `pn=vn` to `tablePath/pn=vn`, which has 
been dropped before.
   
   In conclusion, for the overwrite operation of partitioned table, its 
additional cost is  a serial of  directory rename operations.
   
   For the overwrite operation of non-partitioned table, its cost is double.
   
   For the append operation, its cost is double.
   
   In fact, we can skip commit all task output to stagingDir, we can merge the 
output of all tasks from taskAttemptPaths to tablePath directly.
   
   
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to