|
21 | 21 |
|
22 | 22 | from __future__ import annotations |
23 | 23 |
|
24 | | -from typing import Any, List, TYPE_CHECKING |
| 24 | +from typing import Any, List, TYPE_CHECKING, Literal |
25 | 25 | from datafusion.record_batch import RecordBatchStream |
26 | 26 | from typing_extensions import deprecated |
27 | 27 | from datafusion.plan import LogicalPlan, ExecutionPlan |
@@ -304,6 +304,29 @@ def join( |
304 | 304 | """ |
305 | 305 | return DataFrame(self.df.join(right.df, join_keys, how)) |
306 | 306 |
|
| 307 | + def join_on( |
| 308 | + self, |
| 309 | + right: DataFrame, |
| 310 | + *on_exprs: Expr, |
| 311 | + how: Literal["inner", "left", "right", "full", "semi", "anti"] = "inner", |
| 312 | + ) -> DataFrame: |
| 313 | + """Join two :py:class:`DataFrame`using the specified expressions. |
| 314 | +
|
| 315 | + On expressions are used to support in-equality predicates. Equality |
| 316 | + predicates are correctly optimized |
| 317 | +
|
| 318 | + Args: |
| 319 | + right: Other DataFrame to join with. |
| 320 | + on_exprs: single or multiple (in)-equality predicates. |
| 321 | + how: Type of join to perform. Supported types are "inner", "left", |
| 322 | + "right", "full", "semi", "anti". |
| 323 | +
|
| 324 | + Returns: |
| 325 | + DataFrame after join. |
| 326 | + """ |
| 327 | + exprs = [expr.expr for expr in on_exprs] |
| 328 | + return DataFrame(self.df.join_on(right.df, exprs, how)) |
| 329 | + |
307 | 330 | def explain(self, verbose: bool = False, analyze: bool = False) -> DataFrame: |
308 | 331 | """Return a DataFrame with the explanation of its plan so far. |
309 | 332 |
|
|
0 commit comments