Exchange with bucketing











up vote
1
down vote

favorite












I have two tables with bucketing enabled.



DESCRIBE EXTENDED table1

Table |table1 | |
|Owner |user | |
|Created |Wed Nov 21 16:24:25 CST 2018 | |
|Last Access |Wed Dec 31 18:00:00 CST 1969 | |
|Type |MANAGED | |
|Provider |parquet | |
|Num Buckets |180 | |
|Bucket Columns |[`seq_id`] | |
|Sort Columns |[`seq_id`]


DESCRIBE EXTENDED table2

Table |table2 | |
|Owner |user | |
|Created |Wed Nov 21 16:15:09 CST 2018 | |
|Last Access |Wed Dec 31 18:00:00 CST 1969 | |
|Type |MANAGED | |
|Provider |parquet | |
|Num Buckets |180 | |
|Bucket Columns |[`seq_id`] | |
|Sort Columns |[`seq_id`]


Then I expect that it will let me avoid shuffling (exchange) when I join both of them.



However, exchange is there:



spark.table("table2").join(spark.table("table1"), "seq_id").explain




== Physical Plan ==
Project [seq_id#0, field1#1, ... 165 more fields]
+- SortMergeJoin [seq_id#0], [seq_id#196], Inner
:- *Sort [seq_id#0 ASC NULLS FIRST], false, 0
: +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#0, 200), coordinator[target post-shuffle partition size: 77108864]
: +- *Project [seq_id#0, field1#1, ... 73 more fields]
: +- *Filter isnotnull(seq_id#0)
: +- *FileScan parquet
test2[seq_id#0, field1#1,... 73 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/hive/warehouse/test2..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<seq_id:string,field1:string...
+- *Sort [seq_id#196 ASC NULLS FIRST], false, 0
+- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#196, 200), coordinator[target post-shuffle partition size: 77108864]
+- *Project [line_s#195, seq_id#196, field1#197, ... 69 more fields]
+- *Filter isnotnull(seq_id#196)
+- *FileScan parquet test1[line_s#195,seq_id#196,field1#197,69 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/test1..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<line_s:string,seq_id:string,field1:string,...


I am using Spark 2.2.1, any idea what could be the reason that exchange still happens there?



Tables (table1 and tables2) were created as below:



spark.table("src_table1").write
.bucketBy(180, "seq_id")
.sortBy("seq_id")
.saveAsTable("table1")

spark.table("src_table2").write
.bucketBy(180, "seq_id")
.sortBy("seq_id")
.saveAsTable("table2")


Hive tables src_table1 and src_table2 are parquet format with no buckets.










share|improve this question




























    up vote
    1
    down vote

    favorite












    I have two tables with bucketing enabled.



    DESCRIBE EXTENDED table1

    Table |table1 | |
    |Owner |user | |
    |Created |Wed Nov 21 16:24:25 CST 2018 | |
    |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
    |Type |MANAGED | |
    |Provider |parquet | |
    |Num Buckets |180 | |
    |Bucket Columns |[`seq_id`] | |
    |Sort Columns |[`seq_id`]


    DESCRIBE EXTENDED table2

    Table |table2 | |
    |Owner |user | |
    |Created |Wed Nov 21 16:15:09 CST 2018 | |
    |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
    |Type |MANAGED | |
    |Provider |parquet | |
    |Num Buckets |180 | |
    |Bucket Columns |[`seq_id`] | |
    |Sort Columns |[`seq_id`]


    Then I expect that it will let me avoid shuffling (exchange) when I join both of them.



    However, exchange is there:



    spark.table("table2").join(spark.table("table1"), "seq_id").explain




    == Physical Plan ==
    Project [seq_id#0, field1#1, ... 165 more fields]
    +- SortMergeJoin [seq_id#0], [seq_id#196], Inner
    :- *Sort [seq_id#0 ASC NULLS FIRST], false, 0
    : +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#0, 200), coordinator[target post-shuffle partition size: 77108864]
    : +- *Project [seq_id#0, field1#1, ... 73 more fields]
    : +- *Filter isnotnull(seq_id#0)
    : +- *FileScan parquet
    test2[seq_id#0, field1#1,... 73 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/hive/warehouse/test2..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<seq_id:string,field1:string...
    +- *Sort [seq_id#196 ASC NULLS FIRST], false, 0
    +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#196, 200), coordinator[target post-shuffle partition size: 77108864]
    +- *Project [line_s#195, seq_id#196, field1#197, ... 69 more fields]
    +- *Filter isnotnull(seq_id#196)
    +- *FileScan parquet test1[line_s#195,seq_id#196,field1#197,69 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/test1..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<line_s:string,seq_id:string,field1:string,...


    I am using Spark 2.2.1, any idea what could be the reason that exchange still happens there?



    Tables (table1 and tables2) were created as below:



    spark.table("src_table1").write
    .bucketBy(180, "seq_id")
    .sortBy("seq_id")
    .saveAsTable("table1")

    spark.table("src_table2").write
    .bucketBy(180, "seq_id")
    .sortBy("seq_id")
    .saveAsTable("table2")


    Hive tables src_table1 and src_table2 are parquet format with no buckets.










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have two tables with bucketing enabled.



      DESCRIBE EXTENDED table1

      Table |table1 | |
      |Owner |user | |
      |Created |Wed Nov 21 16:24:25 CST 2018 | |
      |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
      |Type |MANAGED | |
      |Provider |parquet | |
      |Num Buckets |180 | |
      |Bucket Columns |[`seq_id`] | |
      |Sort Columns |[`seq_id`]


      DESCRIBE EXTENDED table2

      Table |table2 | |
      |Owner |user | |
      |Created |Wed Nov 21 16:15:09 CST 2018 | |
      |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
      |Type |MANAGED | |
      |Provider |parquet | |
      |Num Buckets |180 | |
      |Bucket Columns |[`seq_id`] | |
      |Sort Columns |[`seq_id`]


      Then I expect that it will let me avoid shuffling (exchange) when I join both of them.



      However, exchange is there:



      spark.table("table2").join(spark.table("table1"), "seq_id").explain




      == Physical Plan ==
      Project [seq_id#0, field1#1, ... 165 more fields]
      +- SortMergeJoin [seq_id#0], [seq_id#196], Inner
      :- *Sort [seq_id#0 ASC NULLS FIRST], false, 0
      : +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#0, 200), coordinator[target post-shuffle partition size: 77108864]
      : +- *Project [seq_id#0, field1#1, ... 73 more fields]
      : +- *Filter isnotnull(seq_id#0)
      : +- *FileScan parquet
      test2[seq_id#0, field1#1,... 73 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/hive/warehouse/test2..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<seq_id:string,field1:string...
      +- *Sort [seq_id#196 ASC NULLS FIRST], false, 0
      +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#196, 200), coordinator[target post-shuffle partition size: 77108864]
      +- *Project [line_s#195, seq_id#196, field1#197, ... 69 more fields]
      +- *Filter isnotnull(seq_id#196)
      +- *FileScan parquet test1[line_s#195,seq_id#196,field1#197,69 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/test1..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<line_s:string,seq_id:string,field1:string,...


      I am using Spark 2.2.1, any idea what could be the reason that exchange still happens there?



      Tables (table1 and tables2) were created as below:



      spark.table("src_table1").write
      .bucketBy(180, "seq_id")
      .sortBy("seq_id")
      .saveAsTable("table1")

      spark.table("src_table2").write
      .bucketBy(180, "seq_id")
      .sortBy("seq_id")
      .saveAsTable("table2")


      Hive tables src_table1 and src_table2 are parquet format with no buckets.










      share|improve this question















      I have two tables with bucketing enabled.



      DESCRIBE EXTENDED table1

      Table |table1 | |
      |Owner |user | |
      |Created |Wed Nov 21 16:24:25 CST 2018 | |
      |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
      |Type |MANAGED | |
      |Provider |parquet | |
      |Num Buckets |180 | |
      |Bucket Columns |[`seq_id`] | |
      |Sort Columns |[`seq_id`]


      DESCRIBE EXTENDED table2

      Table |table2 | |
      |Owner |user | |
      |Created |Wed Nov 21 16:15:09 CST 2018 | |
      |Last Access |Wed Dec 31 18:00:00 CST 1969 | |
      |Type |MANAGED | |
      |Provider |parquet | |
      |Num Buckets |180 | |
      |Bucket Columns |[`seq_id`] | |
      |Sort Columns |[`seq_id`]


      Then I expect that it will let me avoid shuffling (exchange) when I join both of them.



      However, exchange is there:



      spark.table("table2").join(spark.table("table1"), "seq_id").explain




      == Physical Plan ==
      Project [seq_id#0, field1#1, ... 165 more fields]
      +- SortMergeJoin [seq_id#0], [seq_id#196], Inner
      :- *Sort [seq_id#0 ASC NULLS FIRST], false, 0
      : +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#0, 200), coordinator[target post-shuffle partition size: 77108864]
      : +- *Project [seq_id#0, field1#1, ... 73 more fields]
      : +- *Filter isnotnull(seq_id#0)
      : +- *FileScan parquet
      test2[seq_id#0, field1#1,... 73 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/hive/warehouse/test2..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<seq_id:string,field1:string...
      +- *Sort [seq_id#196 ASC NULLS FIRST], false, 0
      +- Exchange(coordinator id: 713544719) hashpartitioning(seq_id#196, 200), coordinator[target post-shuffle partition size: 77108864]
      +- *Project [line_s#195, seq_id#196, field1#197, ... 69 more fields]
      +- *Filter isnotnull(seq_id#196)
      +- *FileScan parquet test1[line_s#195,seq_id#196,field1#197,69 more fields] Batched: true, Format: Parquet, Location: InMemoryFileIndex[maprfs:/ds/test1..., PartitionFilters: , PushedFilters: [IsNotNull(seq_id)], ReadSchema: struct<line_s:string,seq_id:string,field1:string,...


      I am using Spark 2.2.1, any idea what could be the reason that exchange still happens there?



      Tables (table1 and tables2) were created as below:



      spark.table("src_table1").write
      .bucketBy(180, "seq_id")
      .sortBy("seq_id")
      .saveAsTable("table1")

      spark.table("src_table2").write
      .bucketBy(180, "seq_id")
      .sortBy("seq_id")
      .saveAsTable("table2")


      Hive tables src_table1 and src_table2 are parquet format with no buckets.







      apache-spark apache-spark-sql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 0:16









      user10465355

      968310




      968310










      asked Nov 21 at 23:27









      Tomasz Krol

      187113




      187113
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Seems like adaptive query execution enabled (spark.sql.adaptive.enabled=true) was the problem. After disabling this, exchange is not there anymore. Need to dig more, why it happens.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421867%2fexchange-with-bucketing%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Seems like adaptive query execution enabled (spark.sql.adaptive.enabled=true) was the problem. After disabling this, exchange is not there anymore. Need to dig more, why it happens.






            share|improve this answer

























              up vote
              0
              down vote













              Seems like adaptive query execution enabled (spark.sql.adaptive.enabled=true) was the problem. After disabling this, exchange is not there anymore. Need to dig more, why it happens.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                Seems like adaptive query execution enabled (spark.sql.adaptive.enabled=true) was the problem. After disabling this, exchange is not there anymore. Need to dig more, why it happens.






                share|improve this answer












                Seems like adaptive query execution enabled (spark.sql.adaptive.enabled=true) was the problem. After disabling this, exchange is not there anymore. Need to dig more, why it happens.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 23:19









                Tomasz Krol

                187113




                187113






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421867%2fexchange-with-bucketing%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Catalogne

                    Violoncelliste

                    Héron pourpré