Github user liancheng commented on the pull request:

    https://github.com/apache/spark/pull/8125#issuecomment-132149046
  
    @scwf @watermen I agree that combining small files is a useful feature. 
Essentially, we need to add a `coalesce(n)` when appropriate. But this PR has 
several problems:
    
    1. Instead of providing a general mechanism, it touches all specific 
`HadoopFsRelation` data source and Hive support, which isn't extensible.
    1. What this PR does isn't "combining small files", but split input files 
into a fixed pre-configured size. That's why I gave the 2G file example.
    1. Performance regression issue mentioned above.
    
    Among all 3 problems, personally I think the 1st one is the most important. 
To me, the reason why this PR touches all those individual data sources is 
that, it needs to collect file size information to calculate split number.  My 
suggestion is to split this PR into two parts:
    
    - Coalescing by split number
    - Coalescing by split size
    
    And we can have two separate configurations to control the behavior.  For 
example:
    
    ```sql
    -- (1)
    SET spark.sql.mapper.partitionCount=10;
    SELECT * FROM t;
    
    -- (2)
    SET spark.sql.mapper.parititionSize=256mb;
    SELECT * FROM t;
    ```
    
    The first case adds a `Repartition` plan node to the query plan, and always 
starts 10 mapper tasks. This is equivalent to `DataFrame.coalesce(10)`.  
Instead of touching all those data sources, we add the `Repartition` node at 
query planning phase by checking the value of `spark.sql.mapper.partitionCount` 
(-1 by default, which means don't do combining).  This part should be easier to 
implement.
    
    The second case is somewhat equivalent to this PR, but relies on table 
statistics rather than figuring out file sizes within each data sources via 
Hadoop `FileSystem` API.  This one can be harder since we probably need to 
update current `ANALYZE TABLE` command implementation, but it's a more general 
approach and has bigger potential for other optimization opportunities.
    
    @rxin @marmbrus Any thoughts about this one?


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