Skip to content

Commit c10b0bb

Browse files
authored
Merge pull request #88 from Embucket/snowflake-directed-join
feat(sql): plan Snowflake directed joins
2 parents 4ba4fc0 + b85d7db commit c10b0bb

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ regex = "1.12"
196196
rstest = "0.26.1"
197197
serde_json = "1"
198198
sha2 = "^0.11.0"
199-
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "ff0378d5b2205e839360ab473efe9bcfa520f65f", default-features = false, features = [
199+
sqlparser = { git = "https://github.com/Embucket/datafusion-sqlparser-rs.git", rev = "707457f75c46c99c441b2859ad5bb01e21e5f105", default-features = false, features = [
200200
"std",
201201
"visitor",
202202
] }

‎datafusion/sql/src/unparser/plan.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ impl Unparser<'_> {
609609
let cross_join = ast::Join {
610610
relation: flatten_factor,
611611
global: false,
612+
directed: false,
612613
join_operator: ast::JoinOperator::CrossJoin(
613614
ast::JoinConstraint::None,
614615
),
@@ -1449,6 +1450,7 @@ impl Unparser<'_> {
14491450
let ast_join = ast::Join {
14501451
relation,
14511452
global: false,
1453+
directed: false,
14521454
join_operator: self
14531455
.join_operator_to_sql(join.join_type, join_constraint)?,
14541456
};
@@ -1870,6 +1872,7 @@ impl Unparser<'_> {
18701872
let ast_join = ast::Join {
18711873
relation,
18721874
global: false,
1875+
directed: false,
18731876
join_operator: ast::JoinOperator::AsOf {
18741877
match_condition,
18751878
constraint,

‎datafusion/sql/tests/sql_integration.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,6 +3455,24 @@ fn minus_is_an_alias_for_except() {
34553455
);
34563456
}
34573457

3458+
#[test]
3459+
fn snowflake_directed_join_plans() {
3460+
let sql = "SELECT person.id, orders.order_id \
3461+
FROM person \
3462+
INNER DIRECTED JOIN orders \
3463+
ON person.id = orders.customer_id";
3464+
let plan = logical_plan_with_dialect(sql, &SnowflakeDialect {}).unwrap();
3465+
assert_snapshot!(
3466+
plan,
3467+
@r"
3468+
Projection: person.id, orders.order_id
3469+
Inner Join: Filter: person.id = orders.customer_id
3470+
TableScan: person
3471+
TableScan: orders
3472+
"
3473+
);
3474+
}
3475+
34583476
#[test]
34593477
fn empty_over() {
34603478
let sql = "SELECT order_id, MAX(order_id) OVER () from orders";

0 commit comments

Comments
 (0)