Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-14393

values generated by non-deterministic functions shouldn't change after coalesce or union

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.6.0, 2.0.0, 2.0.1
    • 2.1.0
    • SQL

    Description

      When utilising monotonicallyIncreasingId with a coalesce, it appears that every partition uses the same offset (0) leading to non-monotonically increasing IDs.

      See examples below

      >>> sqlContext.range(10).select(monotonicallyIncreasingId()).show()
      +---------------------------+
      |monotonicallyincreasingid()|
      +---------------------------+
      |                25769803776|
      |                51539607552|
      |                77309411328|
      |               103079215104|
      |               128849018880|
      |               163208757248|
      |               188978561024|
      |               214748364800|
      |               240518168576|
      |               266287972352|
      +---------------------------+
      
      >>> sqlContext.range(10).select(monotonicallyIncreasingId()).coalesce(1).show()
      +---------------------------+
      |monotonicallyincreasingid()|
      +---------------------------+
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      |                          0|
      +---------------------------+
      
      >>> sqlContext.range(10).repartition(5).select(monotonicallyIncreasingId()).coalesce(1).show()
      +---------------------------+
      |monotonicallyincreasingid()|
      +---------------------------+
      |                          0|
      |                          1|
      |                          0|
      |                          0|
      |                          1|
      |                          2|
      |                          3|
      |                          0|
      |                          1|
      |                          2|
      +---------------------------+
      

      Attachments

        Issue Links

          Activity

            People

              mengxr Xiangrui Meng
              jpiper Jason Piper
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: