spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From junegunn <>
Subject [GitHub] spark pull request #16347: [SPARK-18934][SQL] Writing to dynamic partitions ...
Date Tue, 20 Dec 2016 02:37:23 GMT
GitHub user junegunn opened a pull request:

    [SPARK-18934][SQL] Writing to dynamic partitions does not preserve sort order if spills

    ## What changes were proposed in this pull request?
    Make dynamic partition writer perform stable sort by the partition key, so that the sort
order within the partition specified via `sortWithinPartitions` or `SORT BY` is preserved
even when spill occurs.
    ## How was this patch tested?
    Manually tested with the following code snippet and orcdump.
    // FileFormatWriter
    sc.parallelize(1 to 10000000).toDS.withColumn("part", 'value.mod(2))
      .repartition(1, 'part).sortWithinPartitions("value")
      .saveAsTable("test_sort_within")"test_sort_within").filter('part === 0).show"test_sort_within").filter('part === 1).show
    // SparkHiveDynamicPartitionWriterContainer
    //   Insert into an existing Hive table with dynamic partitions
    spark.conf.set("hive.exec.dynamic.partition.mode", "nonstrict")
    sc.parallelize(1 to 10000000).toDS.withColumn("part", 'value.mod(2))
      .repartition(1, 'part).sortWithinPartitions("value")
      .write.mode("overwrite").insertInto("test_sort_within_hive")"test_sort_within_hive").filter('part === 0).show"test_sort_within_hive").filter('part === 1).show
    It was not straightforward to come up with a unit test as the problem is only reproducible
if spill occurs due to memory constraint. I'd appreciate any suggestions or pointers.

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

    $ git pull dynamic-partition-writer-stable-sort

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

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

    This closes #16347
commit bfeccd80ef032cab3525037be3d3e42519619493
Author: Junegunn Choi <>
Date:   2016-12-19T05:54:42Z

    [SPARK-18934][SQL] Writing to dynamic partitions does not preserve sort order if spills


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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message