-
Notifications
You must be signed in to change notification settings - Fork 72
Improve Left/Right/Inner Join #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d54b2a6
43edc68
c199fe7
29a201d
a7c1e30
0fc00db
e32023c
39980fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ def engine(): | |
| remove=True, | ||
| network="dask-sql", | ||
| environment={"POSTGRES_HOST_AUTH_METHOD": "trust"}, | ||
| ports={"5432/tcp": "5432"}, | ||
| ) | ||
|
|
||
| try: | ||
|
|
@@ -32,6 +33,7 @@ def engine(): | |
| # get the address and create the connection | ||
| postgres.reload() | ||
| address = postgres.attrs["NetworkSettings"]["Networks"]["dask-sql"]["IPAddress"] | ||
| address = "localhost" | ||
| port = 5432 | ||
|
|
||
| engine = sqlalchemy.create_engine( | ||
|
|
@@ -126,6 +128,92 @@ def test_join(assert_query_gives_same_result): | |
| ) | ||
|
|
||
|
|
||
| def test_join_lricomplex( | ||
| assert_query_gives_same_result, | ||
| engine, | ||
| user_table_ts, | ||
| user_table_pn, | ||
| user_table_lk, | ||
| user_table_lk2, | ||
| c, | ||
| ): | ||
| # ---------- Panel data | ||
| # Left Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select a.*, b.startdate, b.enddate, b.lk_nullint, b.lk_int, b.lk_str, | ||
| b.lk_float, b.lk_date | ||
| from user_table_pn a left join user_table_lk b | ||
| on a.ids=b.id and b.startdate<=a.dates and a.dates<=b.enddate | ||
| """, | ||
| ["ids", "dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
| ) | ||
| # Right Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select b.*, a.startdate, a.enddate, a.lk_nullint, a.lk_int, a.lk_str, | ||
| a.lk_float, a.lk_date | ||
| from user_table_lk a right join user_table_pn b | ||
| on b.ids=a.id and a.startdate<=b.dates and b.dates<=a.enddate | ||
| """, | ||
| ["ids", "dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
| ) | ||
| # Inner Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select a.*, b.startdate, b.enddate, b.lk_nullint, b.lk_int, b.lk_str, | ||
| b.lk_float, b.lk_date | ||
| from user_table_pn a inner join user_table_lk b | ||
| on a.ids=b.id and b.startdate<=a.dates and a.dates<=b.enddate | ||
| """, | ||
| ["ids", "dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
| ) | ||
|
|
||
| # ---------- Time-series data | ||
| # Left Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select a.*, b.startdate, b.enddate, b.lk_nullint, b.lk_int, b.lk_str, | ||
| b.lk_float, b.lk_date | ||
| from user_table_ts a left join user_table_lk2 b | ||
| on b.startdate<=a.dates and a.dates<=b.enddate | ||
| """, | ||
| ["dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
| ) | ||
| # Right Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select b.*, a.startdate, a.enddate, a.lk_nullint, a.lk_int, a.lk_str, | ||
| a.lk_float, a.lk_date | ||
| from user_table_lk2 a right join user_table_ts b | ||
| on a.startdate<=b.dates and b.dates<=a.enddate | ||
| """, | ||
| ["dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
| ) | ||
| # Inner Join | ||
| assert_query_gives_same_result( | ||
| """ | ||
| select a.*, b.startdate, b.enddate, b.lk_nullint, b.lk_int, b.lk_str, | ||
| b.lk_float, b.lk_date | ||
| from user_table_ts a inner join user_table_lk2 b | ||
| on b.startdate<=a.dates and a.dates<=b.enddate | ||
| """, | ||
| ["dates", "startdate", "enddate"], | ||
| force_dtype="dask", | ||
| check_dtype=True, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious here, Specifying
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how |
||
| ) | ||
|
|
||
|
|
||
| def test_sort(assert_query_gives_same_result): | ||
| assert_query_gives_same_result( | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @flcong, Apologies for not letting you know about this earlier, Once you have tested with a custom PostgreSQL address, please replace that address with the original docker container host address, if not Github Workflow will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I see.