GitHub user xwu0226 opened a pull request:

    https://github.com/apache/spark/pull/13463

    [SPARK-14959][SQL] handle partitioned table directories in distributed 
filesystem

    ## What changes were proposed in this pull request?
    ##### The root cause:
    When `DataSource.resolveRelation` is trying to build `ListingFileCatalog` 
object, `ListLeafFiles` is invoked where a list of `FileStatus` objects are 
retrieved from the provided path. These FileStatus objects include directories 
for the partitions (id=0 and id=2 in the jira). However, these directory 
`FileStatus` objects also try to invoke `getFileBlockLocations` where directory 
is not allowed for `DistributedFileSystem`, hence the exception happens.
    
    This PR is to remove the block of code that invokes `getFileBlockLocations` 
for every FileStatus object of the provided path. Instead, we call 
`HadoopFsRelation.listLeafFiles` directly because this utility method filters 
out the directories before calling `getFileBlockLocations` for generating 
`LocatedFileStatus` objects.
    
    ## How was this patch tested?
    Regtest is run. Manual test:
    ```
    scala> 
spark.read.format("parquet").load("hdfs://bdavm009.svl.ibm.com:8020/user/spark/SPARK-14959_part").show
    +-----+---+
    | text| id|
    +-----+---+
    |hello|  0|
    |world|  0|
    |hello|  1|
    |there|  1|
    +-----+---+
    
           
spark.read.format("orc").load("hdfs://bdavm009.svl.ibm.com:8020/user/spark/SPARK-14959_orc").show
    +-----+---+
    | text| id|
    +-----+---+
    |hello|  0|
    |world|  0|
    |hello|  1|
    |there|  1|
    +-----+---+
    ```
    I also tried it with 2 level of partitioning.
    I have not found a way to add test case that can test a real hdfs file 
location. Any suggestions will be appreciated. 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/xwu0226/spark SPARK-14959

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/13463.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13463
    
----
commit 2f741878b8f357c61d75780fe911f922b4fd7847
Author: Xin Wu <xi...@us.ibm.com>
Date:   2016-06-02T04:30:33Z

    SPARK-14959: handle partitioned table directories in distributed file system

----


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