Commits

Andy Grove authored 64914253731
ARROW-10584: [Rust] [DataFusion] Add SQL support for JOIN ON syntax The goal of this PR is to add SQL support for joins using the explict `<relation> JOIN <relation> ON <clause>` syntax. There are follow-up JIRA issues filed for supporting other forms of join syntax. There is no support for compound identifiers or aliases, so this only works if the output from a join has unique colums names. This is enough to support TPC-H queries. ```sql SELECT l_shipmode, sum(case when o_orderpriority = '1-URGENT' OR o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' AND o_orderpriority <> '2-HIGH' then 1 else 0 end) AS low_line_count FROM lineitem JOIN orders ON l_orderkey = o_orderkey WHERE (l_shipmode = 'MAIL' OR l_shipmode = 'SHIP') AND l_commitdate < l_receiptdate AND l_shipdate < l_commitdate AND l_receiptdate >= '1994-01-01' AND l_receiptdate < '1995-01-01' GROUP BY l_shipmode ORDER BY l_shipmode ``` Plan: ``` Sort: #l_shipmode ASC NULLS FIRST Aggregate: groupBy=[[#l_shipmode]], aggr=[[SUM(CASE WHEN #o_orderpriority Eq Utf8("1-URGENT") Or #o_orderpriority Eq Utf8("2-HIGH") THEN Int64(1) ELSE Int64(0) END) AS high_line_count, SUM(CASE WHEN #o_orderpriority NotEq Utf8("1-URGENT") And #o_orderpriority NotEq Utf8("2-HIGH") THEN Int64(1) ELSE Int64(0) END) AS low_line_count]] Join: l_orderkey = o_orderkey Filter: #l_shipmode Eq Utf8("MAIL") Or #l_shipmode Eq Utf8("SHIP") And #l_commitdate Lt #l_receiptdate And #l_shipdate Lt #l_commitdate And #l_receiptdate GtEq Utf8("1994-01-01") And #l_receiptdate Lt Utf8("1995-01-01") TableScan: lineitem projection=Some([0, 10, 11, 12, 14]) TableScan: orders projection=Some([0, 5]) ``` Results: ``` +------------+-----------------+----------------+ | l_shipmode | high_line_count | low_line_count | +------------+-----------------+----------------+ | SHIP | 6200 | 9262 | | MAIL | 6202 | 9324 | +------------+-----------------+----------------+ Query 12 iteration 0 took 11035 ms ``` Closes #8751 from andygrove/join-sql Authored-by: Andy Grove <andygrove73@gmail.com> Signed-off-by: Andy Grove <andygrove73@gmail.com>