You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "XieJiann (via GitHub)" <gi...@apache.org> on 2023/12/22 05:32:53 UTC
[PR] [feature](Nereids): eliminate left outer join by unique [doris]
XieJiann opened a new pull request, #28853:
URL: https://github.com/apache/doris/pull/28853
## Proposed changes
eliminate left outer join by unique
<!--Describe your changes.-->
## Further comments
If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1867312970
(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 44.89 seconds
stream load tsv: 565 seconds loaded 74807831229 Bytes, about 126 MB/s
stream load json: 19 seconds loaded 2358488459 Bytes, about 118 MB/s
stream load orc: 66 seconds loaded 1101869774 Bytes, about 15 MB/s
stream load parquet: 32 seconds loaded 861443392 Bytes, about 25 MB/s
insert into select: 29.0 seconds inserted 10000000 Rows, about 344K ops/s
storage size: 17183897279 Bytes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871786500
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G', run with scripts in https://github.com/apache/doris/tree/master/tools/tpch-tools
```
Tpch sf100 test result on commit f4589a20b5e93b36459a4d5d69a1d2af88c1ae47, data reload: false
run tpch-sf100 query with default conf and session variables
q1 5428 5091 5136 5091
q2 389 164 167 164
q3 1484 1211 1203 1203
q4 1092 794 810 794
q5 3126 2973 3083 2973
q6 227 142 140 140
q7 980 543 566 543
q8 2157 2254 2214 2214
q9 6685 6651 6667 6651
q10 3180 3182 3186 3182
q11 355 226 223 223
q12 392 241 247 241
q13 4426 3699 3660 3660
q14 268 231 217 217
q15 634 564 564 564
q16 467 413 408 408
q17 1042 523 592 523
q18 7055 6776 6828 6776
q19 1655 1545 1496 1496
q20 569 358 357 357
q21 2889 2428 2499 2428
q22 396 332 328 328
Total cold run time: 44896 ms
Total hot run time: 40176 ms
run tpch-sf100 query with default conf and set session variable runtime_filter_mode=off
q1 5071 5036 5008 5008
q2 341 265 279 265
q3 3384 3336 3319 3319
q4 2137 2001 2018 2001
q5 5962 5934 5916 5916
q6 233 135 135 135
q7 2367 1943 1961 1943
q8 3563 3655 3697 3655
q9 9114 9041 9045 9041
q10 3901 3928 3930 3928
q11 612 499 516 499
q12 821 650 638 638
q13 3898 3212 3187 3187
q14 305 278 273 273
q15 629 561 581 561
q16 574 484 501 484
q17 1993 1843 1820 1820
q18 8707 8357 8408 8357
q19 1749 1667 1659 1659
q20 2302 2018 1987 1987
q21 5806 5403 5374 5374
q22 568 548 495 495
Total cold run time: 64037 ms
Total hot run time: 60545 ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871886888
clang-tidy review says "All clean, LGTM! :+1:"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873672884
PR approved by at least one committer and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871882431
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873610034
(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 46.59 seconds
stream load tsv: 578 seconds loaded 74807831229 Bytes, about 123 MB/s
stream load json: 19 seconds loaded 2358488459 Bytes, about 118 MB/s
stream load orc: 66 seconds loaded 1101869774 Bytes, about 15 MB/s
stream load parquet: 33 seconds loaded 861443392 Bytes, about 24 MB/s
insert into select: 28.1 seconds inserted 10000000 Rows, about 355K ops/s
storage size: 17183749175 Bytes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "xzj7019 (via GitHub)" <gi...@apache.org>.
xzj7019 commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436769414
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUniqueTest.java:
##########
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.util.MemoPatternMatchSupported;
+import org.apache.doris.nereids.util.PlanChecker;
+import org.apache.doris.utframe.TestWithFeService;
+
+import org.junit.jupiter.api.Test;
+
+class EliminateJoinByUniqueTest extends TestWithFeService implements MemoPatternMatchSupported {
+ @Override
+ protected void runBeforeAll() throws Exception {
+ createDatabase("test");
+ connectContext.setDatabase("default_cluster:test");
+ createTables(
+ "CREATE TABLE IF NOT EXISTS t1 (\n"
+ + " id1 int not null,\n"
+ + " id_null int,\n"
+ + ")\n"
+ + "DUPLICATE KEY(id1)\n"
+ + "DISTRIBUTED BY HASH(id1) BUCKETS 10\n"
+ + "PROPERTIES (\"replication_num\" = \"1\")\n",
+ "CREATE TABLE IF NOT EXISTS t2 (\n"
+ + " id2 int not null\n"
+ + ")\n"
+ + "DUPLICATE KEY(id2)\n"
+ + "DISTRIBUTED BY HASH(id2) BUCKETS 10\n"
+ + "PROPERTIES (\"replication_num\" = \"1\")\n");
+ addConstraint("Alter table t1 add constraint uk_t1 unique (id1)");
+ addConstraint("Alter table t1 add constraint id_null unique (id_null)");
+ addConstraint("Alter table t2 add constraint uk_t2 unique (id2)");
+ }
+
+ @Test
+ void testNotNull() throws Exception {
+ String sql = "select t1.id1 from t1 left outer join t2 on t1.id1 = t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .nonMatch(logicalJoin())
+ .printlnTree();
+
+ sql = "select t1.id1 from t1 left outer join t2 on t1.id1 <=> t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .matches(logicalJoin())
+ .printlnTree();
+
+ sql = "select t2.id2 from t1 left outer join t2 on t1.id1 = t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .matches(logicalJoin())
+ .printlnTree();
+ }
+
+ @Test
+ void testNull() throws Exception {
Review Comment:
can we add more cases like multijoin?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873609390
TPC-DS test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G', run with scripts in https://github.com/apache/doris/tree/master/tools/tpcds-tools
```
TPC-DS sf100 test result on commit 9b1935f7185c6777268450c9acbad399bf65ab9a, data reload: false
run tpcds-sf100 query with default conf and session variables
query1 927 371 336 336
query2 6457 1888 1870 1870
query3 6654 209 200 200
query4 26369 22446 22335 22335
query5 4885 524 523 523
query6 269 173 180 173
query7 4566 278 266 266
query8 227 201 193 193
query9 8315 2727 2740 2727
query10 442 240 256 240
query11 16234 15431 15473 15431
query12 130 74 74 74
query13 1646 333 322 322
query14 11527 7050 6993 6993
query15 243 193 189 189
query16 6477 277 261 261
query17 1831 499 488 488
query18 1929 279 258 258
query19 254 140 132 132
query20 84 78 77 77
query21 181 96 93 93
query22 5056 4886 4739 4739
query23 32039 31190 30974 30974
query24 12118 2816 2830 2816
query25 566 341 340 340
query26 1733 149 142 142
query27 2881 285 284 284
query28 6855 1964 1966 1964
query29 2102 396 390 390
query30 285 145 145 145
query31 1066 761 780 761
query32 87 57 54 54
query33 728 271 266 266
query34 880 448 434 434
query35 901 749 743 743
query36 1361 1265 1211 1211
query37 189 73 69 69
query38 3439 3308 3278 3278
query39 1343 1276 1278 1276
query40 297 94 90 90
query41 37 35 34 34
query42 89 90 90 90
query43 553 462 531 462
query44 1086 707 726 707
query45 195 193 183 183
query46 1064 645 636 636
query47 1719 1570 1539 1539
query48 334 263 269 263
query49 1213 322 322 322
query50 720 334 329 329
query51 5330 5276 5339 5276
query52 89 92 86 86
query53 214 158 151 151
query54 1350 572 579 572
query55 98 85 91 85
query56 207 198 193 193
query57 1036 967 943 943
query58 227 210 200 200
query59 2760 2569 2483 2483
query60 245 225 231 225
query61 84 82 81 81
query62 651 464 474 464
query63 167 164 151 151
query64 5806 1739 1643 1643
query65 3325 3258 3268 3258
query66 1341 336 327 327
query67 15788 15469 15489 15469
query68 12317 516 542 516
query69 535 253 249 249
query70 1615 1522 1543 1522
query71 496 233 225 225
query72 5618 3514 3480 3480
query73 2749 312 316 312
query74 7022 6477 6501 6477
query75 4965 2304 2257 2257
query76 6260 1118 1161 1118
query77 693 255 281 255
query78 9076 8736 8676 8676
query79 1032 522 504 504
query80 559 368 377 368
query81 464 207 207 207
query82 212 97 109 97
query83 170 135 137 135
query84 252 53 51 51
query85 1000 281 272 272
query86 385 369 349 349
query87 3508 3425 3367 3367
query88 3076 2259 2262 2259
query89 349 268 267 267
query90 1890 207 214 207
query91 121 99 89 89
query92 63 56 61 56
query93 1922 448 440 440
query94 843 187 187 187
query95 474 415 415 415
query96 626 319 314 314
query97 4258 4130 4182 4130
query98 214 199 192 192
query99 1119 871 856 856
Total cold run time: 293184 ms
Total hot run time: 179178 ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1868692656
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
```
Tpch sf100 test result on commit 3544ba985aa4880cac850a41b030390642901ddc, data reload: false
run tpch-sf100 query with default conf and session variables
q1 4689 4433 4447 4433
q2 368 146 158 146
q3 1476 1258 1242 1242
q4 1112 902 898 898
q5 3185 3185 3174 3174
q6 251 135 132 132
q7 1004 490 489 489
q8 2209 2202 2213 2202
q9 6712 6652 6674 6652
q10 3209 3268 3262 3262
q11 310 194 190 190
q12 358 210 208 208
q13 4543 3822 3832 3822
q14 242 216 216 216
q15 571 524 532 524
q16 441 383 377 377
q17 1010 662 587 587
q18 7018 6761 6720 6720
q19 1516 1441 1420 1420
q20 503 311 322 311
q21 3094 2658 2668 2658
q22 346 276 279 276
Total cold run time: 44167 ms
Total hot run time: 39939 ms
run tpch-sf100 query with default conf and set session variable runtime_filter_mode=off
q1 4348 4371 4349 4349
q2 273 164 169 164
q3 3503 3489 3487 3487
q4 2389 2359 2373 2359
q5 5703 5716 5724 5716
q6 243 122 123 122
q7 2369 1853 1856 1853
q8 3523 3525 3541 3525
q9 9046 8995 8987 8987
q10 3915 4006 4005 4005
q11 485 373 359 359
q12 765 593 596 593
q13 4286 3583 3565 3565
q14 297 261 260 260
q15 576 535 526 526
q16 497 448 475 448
q17 1880 1839 1848 1839
q18 8462 8087 8103 8087
q19 1741 1762 1775 1762
q20 2249 1949 1924 1924
q21 6513 6184 6127 6127
q22 501 418 422 418
Total cold run time: 63564 ms
Total hot run time: 60475 ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873605963
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G', run with scripts in https://github.com/apache/doris/tree/master/tools/tpch-tools
```
Tpch sf100 test result on commit 9b1935f7185c6777268450c9acbad399bf65ab9a, data reload: false
------ Round 1 ----------------------------------
q1 18972 5917 5139 5139
q2 2032 161 148 148
q3 10596 1131 1115 1115
q4 10231 835 838 835
q5 7821 2992 2967 2967
q6 219 136 131 131
q7 921 497 545 497
q8 9272 2066 2064 2064
q9 6926 6472 6398 6398
q10 8229 3054 2959 2959
q11 445 219 225 219
q12 393 228 230 228
q13 18004 3608 3614 3608
q14 240 213 213 213
q15 575 538 532 532
q16 462 400 403 400
q17 989 516 513 513
q18 7359 6719 6697 6697
q19 1610 1376 1429 1376
q20 740 352 324 324
q21 2815 2452 2401 2401
q22 383 328 303 303
Total cold run time: 109234 ms
Total hot run time: 39067 ms
----- Round 2, with runtime_filter_mode=off -----
q1 5149 5072 5136 5072
q2 343 250 250 250
q3 3302 3269 3282 3269
q4 2107 2021 2006 2006
q5 5790 5798 5812 5798
q6 216 123 122 122
q7 2338 1886 1916 1886
q8 3362 3480 3510 3480
q9 8844 8781 8756 8756
q10 3816 3835 3880 3835
q11 596 498 493 493
q12 794 617 638 617
q13 6720 3246 3211 3211
q14 300 276 276 276
q15 596 537 532 532
q16 561 518 515 515
q17 1970 1779 1767 1767
q18 8759 8325 8314 8314
q19 1643 1589 1587 1587
q20 2176 1961 1990 1961
q21 5588 5237 5240 5237
q22 520 469 510 469
Total cold run time: 65490 ms
Total hot run time: 59453 ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871745848
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1868670452
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873575331
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener merged PR #28853:
URL: https://github.com/apache/doris/pull/28853
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436770446
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUniqueTest.java:
##########
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.util.MemoPatternMatchSupported;
+import org.apache.doris.nereids.util.PlanChecker;
+import org.apache.doris.utframe.TestWithFeService;
+
+import org.junit.jupiter.api.Test;
+
+class EliminateJoinByUniqueTest extends TestWithFeService implements MemoPatternMatchSupported {
+ @Override
+ protected void runBeforeAll() throws Exception {
+ createDatabase("test");
+ connectContext.setDatabase("default_cluster:test");
+ createTables(
+ "CREATE TABLE IF NOT EXISTS t1 (\n"
+ + " id1 int not null,\n"
+ + " id_null int,\n"
+ + ")\n"
+ + "DUPLICATE KEY(id1)\n"
+ + "DISTRIBUTED BY HASH(id1) BUCKETS 10\n"
+ + "PROPERTIES (\"replication_num\" = \"1\")\n",
+ "CREATE TABLE IF NOT EXISTS t2 (\n"
+ + " id2 int not null\n"
+ + ")\n"
+ + "DUPLICATE KEY(id2)\n"
+ + "DISTRIBUTED BY HASH(id2) BUCKETS 10\n"
+ + "PROPERTIES (\"replication_num\" = \"1\")\n");
+ addConstraint("Alter table t1 add constraint uk_t1 unique (id1)");
+ addConstraint("Alter table t1 add constraint id_null unique (id_null)");
+ addConstraint("Alter table t2 add constraint uk_t2 unique (id2)");
+ }
+
+ @Test
+ void testNotNull() throws Exception {
+ String sql = "select t1.id1 from t1 left outer join t2 on t1.id1 = t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .nonMatch(logicalJoin())
+ .printlnTree();
+
+ sql = "select t1.id1 from t1 left outer join t2 on t1.id1 <=> t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .matches(logicalJoin())
+ .printlnTree();
+
+ sql = "select t2.id2 from t1 left outer join t2 on t1.id1 = t2.id2";
+ PlanChecker.from(connectContext)
+ .analyze(sql)
+ .rewrite()
+ .matches(logicalJoin())
+ .printlnTree();
+ }
+
+ @Test
+ void testNull() throws Exception {
Review Comment:
multijoin has no difference with the single join
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "xzj7019 (via GitHub)" <gi...@apache.org>.
xzj7019 commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436768260
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUnique.java:
##########
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+/**
+ * Eliminate outer join.
+ */
+public class EliminateJoinByUnique extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalProject(
Review Comment:
can we open the restriction for the project on join to support more scenario, like multi join?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436769984
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUnique.java:
##########
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+/**
+ * Eliminate outer join.
+ */
+public class EliminateJoinByUnique extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalProject(
Review Comment:
only project can prune right output, where the join can be eliminated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1867263201
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1867261558
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436782251
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUnique.java:
##########
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+/**
+ * Eliminate outer join.
+ */
+public class EliminateJoinByUnique extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalProject(
+ logicalJoin().when(join -> join.getJoinType().isLeftOuterJoin())
+ ).then(project -> {
+ LogicalJoin<?, ?> join = project.child();
+ if (!join.left().getOutputSet().containsAll(project.getInputSlots())) {
+ return project;
+ }
+ if (join.getHashJoinConjuncts().stream().anyMatch(NullSafeEqual.class::isInstance)) {
+ // TODO: support null safe equals in fd and this
+ return project;
+ }
+ if (!project.getLogicalProperties().getFunctionalDependencies().isUnique(project.getOutputSet())) {
Review Comment:
yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1868697621
(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 43.46 seconds
stream load tsv: 567 seconds loaded 74807831229 Bytes, about 125 MB/s
stream load json: 19 seconds loaded 2358488459 Bytes, about 118 MB/s
stream load orc: 66 seconds loaded 1101869774 Bytes, about 15 MB/s
stream load parquet: 33 seconds loaded 861443392 Bytes, about 24 MB/s
insert into select: 28.7 seconds inserted 10000000 Rows, about 348K ops/s
storage size: 17184186366 Bytes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "xzj7019 (via GitHub)" <gi...@apache.org>.
xzj7019 commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436769225
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUnique.java:
##########
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+/**
+ * Eliminate outer join.
+ */
+public class EliminateJoinByUnique extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalProject(
+ logicalJoin().when(join -> join.getJoinType().isLeftOuterJoin())
+ ).then(project -> {
+ LogicalJoin<?, ?> join = project.child();
+ if (!join.left().getOutputSet().containsAll(project.getInputSlots())) {
+ return project;
+ }
+ if (join.getHashJoinConjuncts().stream().anyMatch(NullSafeEqual.class::isInstance)) {
+ // TODO: support null safe equals in fd and this
+ return project;
+ }
+ if (!project.getLogicalProperties().getFunctionalDependencies().isUnique(project.getOutputSet())) {
Review Comment:
Is it based on the fd derivation on both side unique key property?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "xzj7019 (via GitHub)" <gi...@apache.org>.
xzj7019 commented on code in PR #28853:
URL: https://github.com/apache/doris/pull/28853#discussion_r1436768260
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/EliminateJoinByUnique.java:
##########
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.rules.rewrite;
+
+import org.apache.doris.nereids.rules.Rule;
+import org.apache.doris.nereids.rules.RuleType;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+
+/**
+ * Eliminate outer join.
+ */
+public class EliminateJoinByUnique extends OneRewriteRuleFactory {
+ @Override
+ public Rule build() {
+ return logicalProject(
Review Comment:
can we open the restriction for the project on join?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871791571
(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 49.01 seconds
stream load tsv: 576 seconds loaded 74807831229 Bytes, about 123 MB/s
stream load json: 19 seconds loaded 2358488459 Bytes, about 118 MB/s
stream load orc: 66 seconds loaded 1101869774 Bytes, about 15 MB/s
stream load parquet: 32 seconds loaded 861443392 Bytes, about 25 MB/s
insert into select: 27.7 seconds inserted 10000000 Rows, about 361K ops/s
storage size: 17184141038 Bytes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1871745876
PR approved by anyone and no changes requested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873606237
TPC-H test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G', run with scripts in https://github.com/apache/doris/tree/master/tools/tpch-tools
```
Tpch sf100 test result on commit 9b1935f7185c6777268450c9acbad399bf65ab9a, data reload: false
run tpch-sf100 query with default conf and session variables
q1 5416 5179 5173 5173
q2 391 163 160 160
q3 1463 1155 1216 1155
q4 1099 821 880 821
q5 3118 3106 3128 3106
q6 227 148 131 131
q7 990 547 513 513
q8 2174 2252 2299 2252
q9 6717 6652 6706 6652
q10 3196 3177 3089 3089
q11 344 218 213 213
q12 388 233 235 233
q13 4415 3675 3628 3628
q14 262 211 214 211
q15 615 552 546 546
q16 465 402 411 402
q17 1053 575 526 526
q18 7079 6685 6768 6685
q19 1685 1582 1591 1582
q20 551 346 347 346
q21 2877 2410 2482 2410
q22 378 305 315 305
Total cold run time: 44903 ms
Total hot run time: 40139 ms
run tpch-sf100 query with default conf and set session variable runtime_filter_mode=off
q1 5081 5064 5035 5035
q2 331 244 267 244
q3 3384 3327 3280 3280
q4 2108 2058 2048 2048
q5 5938 5937 5960 5937
q6 222 129 124 124
q7 2383 1944 1933 1933
q8 3574 3672 3678 3672
q9 9043 8963 8968 8963
q10 3885 3912 3935 3912
q11 578 504 484 484
q12 797 662 621 621
q13 3881 3212 3215 3212
q14 313 286 270 270
q15 629 544 543 543
q16 550 525 503 503
q17 2048 1830 1819 1819
q18 8728 8291 8393 8291
q19 1753 1704 1714 1704
q20 2309 2002 1990 1990
q21 5724 5451 5434 5434
q22 572 511 513 511
Total cold run time: 63831 ms
Total hot run time: 60530 ms
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873577564
clang-tidy review says "All clean, LGTM! :+1:"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [feature](Nereids): eliminate left outer join by unique [doris]
Posted by "XieJiann (via GitHub)" <gi...@apache.org>.
XieJiann commented on PR #28853:
URL: https://github.com/apache/doris/pull/28853#issuecomment-1873593422
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org