jackwener commented on code in PR #4863:
URL: https://github.com/apache/arrow-datafusion/pull/4863#discussion_r1064676648
##########
datafusion/sql/src/relation/join.rs:
##########
@@ -142,10 +142,29 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
.build()
}
JoinConstraint::Natural => {
- // https://issues.apache.org/jira/browse/ARROW-10727
- Err(DataFusionError::NotImplemented(
- "NATURAL JOIN is not supported
(https://issues.apache.org/jira/browse/ARROW-10727)".to_string(),
- ))
+ // TODO: what if no common join cols? -> becomes cross join
Review Comment:
```suggestion
```
Yes, we should convert it to cross-join.
like pg:
```sql
-- create
CREATE TABLE a (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL
);
CREATE TABLE b (
id1 INTEGER PRIMARY KEY,
name1 TEXT NOT NULL,
dept1 TEXT NOT NULL
);
-- insert
INSERT INTO a VALUES (0001, 'Clark', 'Sales');
INSERT INTO b VALUES (0001, 'Clark', 'Sales');
INSERT INTO a VALUES (0002, 'Ava', 'Sales');
INSERT INTO b VALUES (0002, 'Ava', 'Sales');
-- fetch
SELECT * FROM a natural join b;
id | name | dept | id1 | name1 | dept1
----+-------+-------+-----+-------+-------
1 | Clark | Sales | 1 | Clark | Sales
1 | Clark | Sales | 2 | Ava | Sales
2 | Ava | Sales | 1 | Clark | Sales
2 | Ava | Sales | 2 | Ava | Sales
(4 rows)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]