@@ -319,6 +319,21 @@ select * from temp_1 t1 inner join test_simple_seq_2 seq on t1.colA = seq.col2 ;
319
319
18 9 666 86073 8 18
320
320
19 3 701 34675 9 19
321
321
322
+ query rowsort +ensure:nlj_init_check
323
+ select * from temp_2 t2 inner join test_simple_seq_2 seq on t2.colA = seq.col2 ;
324
+ ----
325
+ 10 290 0 0 10
326
+ 11 878 1 1 11
327
+ 12 170 2 2 12
328
+ 13 332 3 3 13
329
+ 14 680 4 4 14
330
+ 15 2 5 5 15
331
+ 16 552 6 6 16
332
+ 17 561 7 7 17
333
+ 18 398 8 8 18
334
+ 19 974 9 9 19
335
+
336
+
322
337
query rowsort
323
338
select * from __mock_table_1 m1 inner join temp_1 t1 on t1.colA = m1.colB;
324
339
----
@@ -331,6 +346,12 @@ select * from temp_1 t1 inner join temp_2 t2 on t1.colD = t2.colA;
331
346
60 5 4347 34 34 311 4
332
347
333
348
349
+ query rowsort ensure:nlj_init_check
350
+ select * from __mock_table_1 m1 inner join temp_2 t2 on t2.colA = m1.colB;
351
+ ----
352
+ 0 0 0 142 0
353
+
354
+
334
355
# Non-eq condition
335
356
query rowsort +ensure:nlj_init_check
336
357
select * from temp_2 t2 inner join test_simple_seq_2 s2 on t2.colB < s2.col2;
@@ -363,6 +384,26 @@ create table t2(v1 int, v2 int);
363
384
statement ok
364
385
insert into t2 values (0, 45), (0, 45), (0, 65), (1, 45), (1, 45), (1, 65), (2, 45);
365
386
387
+ statement ok
388
+ create table t3(v1 int, v2 int);
389
+
390
+ statement ok
391
+ insert into t3 values
392
+ (0, 1),
393
+ (1, 1),
394
+ (2, 1),
395
+ (3, 1),
396
+ (4, 1),
397
+ (5, 1),
398
+ (6, 1),
399
+ (0, 2),
400
+ (1, 2),
401
+ (2, 2),
402
+ (3, 2),
403
+ (4, 2),
404
+ (5, 2),
405
+ (6, 2);
406
+
366
407
query rowsort +ensure:nlj_init_check
367
408
select * from temp_2 inner join t2 on v2 = colA;
368
409
----
@@ -375,6 +416,82 @@ select * from temp_2 inner join t2 on v2 = colA;
375
416
45 518 5 2 45
376
417
377
418
419
+ query rowsort +ensure:nlj_init_check
420
+ select * from t3 inner join t3 temp on t3.v1 = temp.v2;
421
+ ----
422
+ 1 1 0 1
423
+ 1 2 0 1
424
+ 1 1 1 1
425
+ 1 2 1 1
426
+ 1 1 2 1
427
+ 1 2 2 1
428
+ 1 1 3 1
429
+ 1 2 3 1
430
+ 1 1 4 1
431
+ 1 2 4 1
432
+ 1 1 5 1
433
+ 1 2 5 1
434
+ 1 1 6 1
435
+ 1 2 6 1
436
+ 2 1 0 2
437
+ 2 2 0 2
438
+ 2 1 1 2
439
+ 2 2 1 2
440
+ 2 1 2 2
441
+ 2 2 2 2
442
+ 2 1 3 2
443
+ 2 2 3 2
444
+ 2 1 4 2
445
+ 2 2 4 2
446
+ 2 1 5 2
447
+ 2 2 5 2
448
+ 2 1 6 2
449
+ 2 2 6 2
450
+
451
+
452
+ query rowsort +ensure:nlj_init_check
453
+ select * from t3 left join t3 temp on t3.v1 = temp.v2;
454
+ ----
455
+ 1 1 0 1
456
+ 1 2 0 1
457
+ 1 1 1 1
458
+ 1 2 1 1
459
+ 1 1 2 1
460
+ 1 2 2 1
461
+ 1 1 3 1
462
+ 1 2 3 1
463
+ 1 1 4 1
464
+ 1 2 4 1
465
+ 1 1 5 1
466
+ 1 2 5 1
467
+ 1 1 6 1
468
+ 1 2 6 1
469
+ 2 1 0 2
470
+ 2 2 0 2
471
+ 2 1 1 2
472
+ 2 2 1 2
473
+ 2 1 2 2
474
+ 2 2 2 2
475
+ 2 1 3 2
476
+ 2 2 3 2
477
+ 2 1 4 2
478
+ 2 2 4 2
479
+ 2 1 5 2
480
+ 2 2 5 2
481
+ 2 1 6 2
482
+ 2 2 6 2
483
+ 6 1 integer_null integer_null
484
+ 6 2 integer_null integer_null
485
+ 5 1 integer_null integer_null
486
+ 5 2 integer_null integer_null
487
+ 3 1 integer_null integer_null
488
+ 3 2 integer_null integer_null
489
+ 4 1 integer_null integer_null
490
+ 4 2 integer_null integer_null
491
+ 0 1 integer_null integer_null
492
+ 0 2 integer_null integer_null
493
+
494
+
378
495
query rowsort +ensure:nlj_init_check
379
496
select * from temp_3 t3 inner join temp_2 t2 on t3.colB = t2.colA;
380
497
----
@@ -390,6 +507,33 @@ select * from temp_3 t3 inner join temp_2 t2 on t3.colB = t2.colA;
390
507
16 52 52 276 2
391
508
18 38 38 194 8
392
509
510
+
511
+ query rowsort +ensure:nlj_init_check
512
+ select * from temp_3 t3 left join temp_2 t2 on t3.colB = t2.colA;
513
+ ----
514
+ 5 29 29 538 9
515
+ 6 52 52 276 2
516
+ 3 52 52 276 2
517
+ 7 88 88 241 8
518
+ 8 14 14 680 4
519
+ 9 52 52 276 2
520
+ 12 17 17 561 7
521
+ 13 52 52 276 2
522
+ 15 2 2 837 2
523
+ 16 52 52 276 2
524
+ 18 38 38 194 8
525
+ 20 739 integer_null integer_null integer_null
526
+ 19 974 integer_null integer_null integer_null
527
+ 17 561 integer_null integer_null integer_null
528
+ 14 680 integer_null integer_null integer_null
529
+ 1 993 integer_null integer_null integer_null
530
+ 4 240 integer_null integer_null integer_null
531
+ 10 290 integer_null integer_null integer_null
532
+ 2 837 integer_null integer_null integer_null
533
+ 11 878 integer_null integer_null integer_null
534
+ 0 142 integer_null integer_null integer_null
535
+
536
+
393
537
query rowsort +ensure:nlj_init_check
394
538
select * from
395
539
(select * from temp_2 where colB < 10) t2 inner join
@@ -398,3 +542,33 @@ select * from
398
542
----
399
543
15 2 5 34
400
544
50 8 0 34
545
+
546
+
547
+ # Composite Key
548
+ query rowsort +ensure:nlj_init_check
549
+ select * from temp_1 t1 inner join temp_2 t2 on t1.colB = t2.colA and t1.colA = t2.colC ;
550
+ ----
551
+ 8 8 3074 56174 8 194 8
552
+
553
+
554
+ query rowsort +ensure:nlj_init_check
555
+ select * from temp_1 t1 inner join temp_2 t2 on t1.colC = t2.colB and t1.colB = t2.colC;
556
+ ----
557
+ 6 2 170 92798 12 170 2
558
+ 10 8 398 60977 18 398 8
559
+ 19 3 701 34675 33 701 3
560
+
561
+
562
+ # Switch left and right table column expressions
563
+ query rowsort +ensure:nlj_init_check
564
+ select * from temp_1 t1 inner join temp_2 t2 on t1.colB = t2.colA and t2.colC = t1.colA ;
565
+ ----
566
+ 8 8 3074 56174 8 194 8
567
+
568
+
569
+ query rowsort +ensure:nlj_init_check
570
+ select * from temp_1 t1 inner join temp_2 t2 on t1.colC = t2.colB and t2.colC = t1.colB ;
571
+ ----
572
+ 6 2 170 92798 12 170 2
573
+ 10 8 398 60977 18 398 8
574
+ 19 3 701 34675 33 701 3
0 commit comments