Skip to content

Commit c8c9f34

Browse files
committed
fix: struct.slt, update.slt and lateral join
1 parent c4a2a78 commit c8c9f34

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

datafusion/sql/src/relation/join.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ pub(crate) fn is_lateral_join(join: &Join) -> Result<bool> {
186186
let is_lateral_syntax = is_lateral(&join.relation);
187187
let is_apply_syntax = match join.join_operator {
188188
JoinOperator::FullOuter(..)
189+
| JoinOperator::Right(..)
189190
| JoinOperator::RightOuter(..)
190191
| JoinOperator::RightAnti(..)
191192
| JoinOperator::RightSemi(..)

datafusion/sql/src/statement.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -942,18 +942,24 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
942942
returning,
943943
or,
944944
} => {
945-
let from =
945+
let froms =
946946
from.map(|update_table_from_kind| match update_table_from_kind {
947-
UpdateTableFromKind::BeforeSet(from) => from[0].clone(),
948-
UpdateTableFromKind::AfterSet(from) => from[0].clone(),
947+
UpdateTableFromKind::BeforeSet(froms) => froms.clone(),
948+
UpdateTableFromKind::AfterSet(froms) => froms.clone(),
949949
});
950+
// TODO: support multiple tables in UPDATE SET FROM
951+
if froms.clone().is_some_and(|f| f.len() > 1) {
952+
println!("---------------------------------------------");
953+
plan_err!("Multiple tables in UPDATE SET FROM not yet supported")?;
954+
}
955+
let update_from = froms.map(|f| f.first().unwrap().clone());
950956
if returning.is_some() {
951957
plan_err!("Update-returning clause not yet supported")?;
952958
}
953959
if or.is_some() {
954960
plan_err!("ON conflict not supported")?;
955961
}
956-
self.update_to_plan(table, assignments, from, selection)
962+
self.update_to_plan(table, assignments, update_from, selection)
957963
}
958964

959965
Statement::Delete(Delete {

datafusion/sqllogictest/test_files/struct.slt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ drop table struct_values;
286286
statement ok
287287
CREATE OR REPLACE VIEW complex_view AS
288288
SELECT {
289-
'user': {
289+
'user_information': {
290290
'info': {
291291
'personal': {
292292
'name': 'John Doe',
@@ -347,22 +347,22 @@ SELECT {
347347
} AS complex_data;
348348

349349
query T
350-
SELECT complex_data.user.info.personal.name FROM complex_view;
350+
SELECT complex_data.user_information.info.personal.name FROM complex_view;
351351
----
352352
John Doe
353353

354354
query I
355-
SELECT complex_data.user.info.personal.age FROM complex_view;
355+
SELECT complex_data.user_information.info.personal.age FROM complex_view;
356356
----
357357
30
358358

359359
query T
360-
SELECT complex_data.user.info.address.city FROM complex_view;
360+
SELECT complex_data.user_information.info.address.city FROM complex_view;
361361
----
362362
Anytown
363363

364364
query T
365-
SELECT complex_data.user.preferences.languages[2] FROM complex_view;
365+
SELECT complex_data.user_information.preferences.languages[2] FROM complex_view;
366366
----
367367
es
368368

datafusion/sqllogictest/test_files/update.slt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ physical_plan_error This feature is not implemented: Unsupported logical plan: D
7878
statement ok
7979
create table t3(a int, b varchar, c double, d int);
8080

81-
# set from multiple tables, sqlparser only supports from one table
82-
query error DataFusion error: SQL error: ParserError\("Expected end of statement, found: ,"\)
81+
# set from multiple tables, DataFusion only supports from one table
82+
query error DataFusion error: Error during planning: Multiple tables in UPDATE SET FROM not yet supported
8383
explain update t1 set b = t2.b, c = t3.a, d = 1 from t2, t3 where t1.a = t2.a and t1.a = t3.a;
8484

8585
# test table alias

0 commit comments

Comments
 (0)