-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression in updating equi-join optimization (#686)
- Loading branch information
Showing
10 changed files
with
160 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
crates/arroyo-planner/src/test/queries/updating_filter_join.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--fail=Updating joins must include an equijoin condition | ||
|
||
CREATE TABLE cars ( | ||
timestamp TIMESTAMP, | ||
car_id TEXT, | ||
driver_id BIGINT, | ||
event_type TEXT, | ||
location TEXT | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$input_dir/cars.json', | ||
format = 'json', | ||
type = 'source', | ||
event_time_field = 'timestamp' | ||
); | ||
|
||
CREATE TABLE passengers ( | ||
timestamp TIMESTAMP, | ||
passenger_id BIGINT | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$input_dir/cars.json', | ||
format = 'json', | ||
type = 'source', | ||
event_time_field = 'timestamp' | ||
); | ||
|
||
select passenger_id, car_id | ||
from passengers | ||
join cars ON passenger_id < car_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 50 additions & 4 deletions
54
crates/arroyo-sql-testing/golden_outputs/updating_inner_join.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,50 @@ | ||
{"before":null,"after":{"left_counter":1,"counter_mod_2":0,"right_count":1},"op":"c"} | ||
{"before":null,"after":{"left_counter":1,"counter_mod_2":1,"right_count":1},"op":"c"} | ||
{"before":null,"after":{"left_counter":2,"counter_mod_2":0,"right_count":2},"op":"c"} | ||
{"before":{"left_counter":1,"counter_mod_2":0,"right_count":1},"after":null,"op":"d"} | ||
{"before":null,"after":{"left_count":1,"right_count":1},"op":"c"} | ||
{"before":null,"after":{"left_count":3,"right_count":3},"op":"c"} | ||
{"before":null,"after":{"left_count":5,"right_count":5},"op":"c"} | ||
{"before":null,"after":{"left_count":7,"right_count":7},"op":"c"} | ||
{"before":null,"after":{"left_count":9,"right_count":9},"op":"c"} | ||
{"before":null,"after":{"left_count":11,"right_count":11},"op":"c"} | ||
{"before":null,"after":{"left_count":13,"right_count":13},"op":"c"} | ||
{"before":null,"after":{"left_count":15,"right_count":15},"op":"c"} | ||
{"before":null,"after":{"left_count":17,"right_count":17},"op":"c"} | ||
{"before":null,"after":{"left_count":19,"right_count":19},"op":"c"} | ||
{"before":null,"after":{"left_count":21,"right_count":21},"op":"c"} | ||
{"before":null,"after":{"left_count":23,"right_count":23},"op":"c"} | ||
{"before":null,"after":{"left_count":25,"right_count":25},"op":"c"} | ||
{"before":null,"after":{"left_count":27,"right_count":27},"op":"c"} | ||
{"before":null,"after":{"left_count":29,"right_count":29},"op":"c"} | ||
{"before":null,"after":{"left_count":31,"right_count":31},"op":"c"} | ||
{"before":null,"after":{"left_count":33,"right_count":33},"op":"c"} | ||
{"before":null,"after":{"left_count":35,"right_count":35},"op":"c"} | ||
{"before":null,"after":{"left_count":37,"right_count":37},"op":"c"} | ||
{"before":null,"after":{"left_count":39,"right_count":39},"op":"c"} | ||
{"before":null,"after":{"left_count":41,"right_count":41},"op":"c"} | ||
{"before":null,"after":{"left_count":43,"right_count":43},"op":"c"} | ||
{"before":null,"after":{"left_count":45,"right_count":45},"op":"c"} | ||
{"before":null,"after":{"left_count":47,"right_count":47},"op":"c"} | ||
{"before":null,"after":{"left_count":49,"right_count":49},"op":"c"} | ||
{"before":null,"after":{"left_count":51,"right_count":51},"op":"c"} | ||
{"before":null,"after":{"left_count":53,"right_count":53},"op":"c"} | ||
{"before":null,"after":{"left_count":55,"right_count":55},"op":"c"} | ||
{"before":null,"after":{"left_count":57,"right_count":57},"op":"c"} | ||
{"before":null,"after":{"left_count":59,"right_count":59},"op":"c"} | ||
{"before":null,"after":{"left_count":61,"right_count":61},"op":"c"} | ||
{"before":null,"after":{"left_count":63,"right_count":63},"op":"c"} | ||
{"before":null,"after":{"left_count":65,"right_count":65},"op":"c"} | ||
{"before":null,"after":{"left_count":67,"right_count":67},"op":"c"} | ||
{"before":null,"after":{"left_count":69,"right_count":69},"op":"c"} | ||
{"before":null,"after":{"left_count":71,"right_count":71},"op":"c"} | ||
{"before":null,"after":{"left_count":73,"right_count":73},"op":"c"} | ||
{"before":null,"after":{"left_count":75,"right_count":75},"op":"c"} | ||
{"before":null,"after":{"left_count":77,"right_count":77},"op":"c"} | ||
{"before":null,"after":{"left_count":79,"right_count":79},"op":"c"} | ||
{"before":null,"after":{"left_count":81,"right_count":81},"op":"c"} | ||
{"before":null,"after":{"left_count":83,"right_count":83},"op":"c"} | ||
{"before":null,"after":{"left_count":85,"right_count":85},"op":"c"} | ||
{"before":null,"after":{"left_count":87,"right_count":87},"op":"c"} | ||
{"before":null,"after":{"left_count":89,"right_count":89},"op":"c"} | ||
{"before":null,"after":{"left_count":91,"right_count":91},"op":"c"} | ||
{"before":null,"after":{"left_count":93,"right_count":93},"op":"c"} | ||
{"before":null,"after":{"left_count":95,"right_count":95},"op":"c"} | ||
{"before":null,"after":{"left_count":97,"right_count":97},"op":"c"} | ||
{"before":null,"after":{"left_count":99,"right_count":99},"op":"c"} |
53 changes: 28 additions & 25 deletions
53
crates/arroyo-sql-testing/src/test/queries/updating_inner_join.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
--fail=Error during planning: can't handle updating right side of join | ||
CREATE TABLE impulse ( | ||
timestamp TIMESTAMP, | ||
counter bigint unsigned not null, | ||
subtask_index bigint unsigned not null | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$input_dir/impulse.json', | ||
format = 'json', | ||
type = 'source', | ||
event_time_field = 'timestamp' | ||
); | ||
timestamp TIMESTAMP, | ||
counter bigint unsigned not null, | ||
subtask_index bigint unsigned not null | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$input_dir/impulse.json', | ||
format = 'json', | ||
type = 'source', | ||
event_time_field = 'timestamp' | ||
); | ||
|
||
|
||
CREATE TABLE output ( | ||
left_counter bigint, | ||
counter_mod_2 bigint, | ||
right_count bigint | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$output_path', | ||
format = 'debezium_json', | ||
type = 'sink' | ||
); | ||
CREATE VIEW impulse_odd AS ( | ||
SELECT * FROM impulse | ||
WHERE counter % 2 == 1 | ||
); | ||
|
||
INSERT INTO output | ||
select counter as left_counter, counter_mod_2, right_count from impulse inner join | ||
(select counter % 2 as counter_mod_2, cast(count(*) as bigint UNSIGNED) as right_count from impulse where counter < 3 group by 1) | ||
on counter = right_count where counter < 3; | ||
CREATE TABLE output ( | ||
left_count bigint, | ||
right_count bigint | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$output_path', | ||
format = 'debezium_json', | ||
type = 'sink' | ||
); | ||
|
||
INSERT INTO output | ||
SELECT A.counter, B.counter | ||
FROM impulse A | ||
JOIN impulse_odd B ON A.counter = B.counter; |
29 changes: 29 additions & 0 deletions
29
crates/arroyo-sql-testing/src/test/queries/updating_inner_join_with_updating.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--fail=Error during planning: can't handle updating right side of join | ||
CREATE TABLE impulse ( | ||
timestamp TIMESTAMP, | ||
counter bigint unsigned not null, | ||
subtask_index bigint unsigned not null | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$input_dir/impulse.json', | ||
format = 'json', | ||
type = 'source', | ||
event_time_field = 'timestamp' | ||
); | ||
|
||
|
||
CREATE TABLE output ( | ||
left_counter bigint, | ||
counter_mod_2 bigint, | ||
right_count bigint | ||
) WITH ( | ||
connector = 'single_file', | ||
path = '$output_path', | ||
format = 'debezium_json', | ||
type = 'sink' | ||
); | ||
|
||
INSERT INTO output | ||
select counter as left_counter, counter_mod_2, right_count from impulse inner join | ||
(select counter % 2 as counter_mod_2, cast(count(*) as bigint UNSIGNED) as right_count from impulse where counter < 3 group by 1) | ||
on counter = right_count where counter < 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters