Skip to content

Commit 6479e43

Browse files
authored
Support JOIN pipe operator (#17969)
* support WHERE pipe operator * support order by * support limit * select pipe * extend support * document supported pipe operators in user guide * fmt * fix where pipe before extend * support AS * support union * support intersection * support except * support aggregate * support join operator * support pivot * remove unused * revert parquet-testing * remove simon * move docs to select.md * remove unnecessary comments * back out pivot operator * remove prompt marker
1 parent 73b1f2b commit 6479e43

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

datafusion/sql/src/query.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
194194
group_by_expr,
195195
planner_context,
196196
),
197+
PipeOperator::Join(join) => {
198+
self.parse_relation_join(plan, join, planner_context)
199+
}
197200

198201
x => not_impl_err!("`{x}` pipe operator is not supported yet"),
199202
}

datafusion/sql/src/relation/join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
4343
Ok(left)
4444
}
4545

46-
fn parse_relation_join(
46+
pub(crate) fn parse_relation_join(
4747
&self,
4848
left: LogicalPlan,
4949
join: Join,

datafusion/sqllogictest/test_files/pipe_operator.slt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,21 @@ query TII rowsort
177177
|> WHERE num_items > 1;
178178
----
179179
apples 2 9
180+
181+
# JOIN pipe
182+
query TII
183+
(
184+
SELECT 'apples' AS item, 2 AS sales
185+
UNION ALL
186+
SELECT 'bananas' AS item, 5 AS sales
187+
)
188+
|> AS produce_sales
189+
|> LEFT JOIN
190+
(
191+
SELECT "apples" AS item, 123 AS id
192+
) AS produce_data
193+
ON produce_sales.item = produce_data.item
194+
|> SELECT produce_sales.item, sales, id;
195+
----
196+
apples 2 123
197+
bananas 5 NULL

docs/source/user-guide/sql/select.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ DataFusion currently supports the following pipe operators:
350350
- [INTERSECT](#pipe_intersect)
351351
- [EXCEPT](#pipe_except)
352352
- [AGGREGATE](#pipe_aggregate)
353+
- [JOIN](#pipe_join)
353354

354355
(pipe_where)=
355356

@@ -514,3 +515,28 @@ select * from range(0,3)
514515
| 3 |
515516
+-------+
516517
```
518+
519+
(pipe_join)=
520+
521+
### JOIN
522+
523+
```sql
524+
(
525+
SELECT 'apples' AS item, 2 AS sales
526+
UNION ALL
527+
SELECT 'bananas' AS item, 5 AS sales
528+
)
529+
|> AS produce_sales
530+
|> LEFT JOIN
531+
(
532+
SELECT 'apples' AS item, 123 AS id
533+
) AS produce_data
534+
ON produce_sales.item = produce_data.item
535+
|> SELECT produce_sales.item, sales, id;
536+
+--------+-------+------+
537+
| item | sales | id |
538+
+--------+-------+------+
539+
| apples | 2 | 123 |
540+
| bananas| 5 | NULL |
541+
+--------+-------+------+
542+
```

0 commit comments

Comments
 (0)