-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT]: sql tbl alias, and compount ident for joins (#3066)
- Loading branch information
1 parent
69fef20
commit e4c6f3f
Showing
5 changed files
with
120 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import daft | ||
from daft import col | ||
|
||
|
||
def test_joins_using(): | ||
df1 = daft.from_pydict({"idx": [1, 2], "val": [10, 20]}) | ||
df2 = daft.from_pydict({"idx": [1, 2], "score": [0.1, 0.2]}) | ||
|
||
df_sql = daft.sql("select * from df1 join df2 using (idx)") | ||
actual = df_sql.collect().to_pydict() | ||
|
||
expected = df1.join(df2, on="idx").collect().to_pydict() | ||
|
||
assert actual == expected | ||
|
||
|
||
def test_joins_with_alias(): | ||
df1 = daft.from_pydict({"idx": [1, 2], "val": [10, 20]}) | ||
df2 = daft.from_pydict({"idx": [1, 2], "score": [0.1, 0.2]}) | ||
|
||
df_sql = daft.sql("select * from df1 as foo join df2 as bar on (foo.idx=bar.idx) where bar.score>0.1") | ||
|
||
actual = df_sql.collect().to_pydict() | ||
|
||
expected = df1.join(df2, on="idx").filter(col("score") > 0.1).collect().to_pydict() | ||
|
||
assert actual == expected |
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