File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
crates/runtime/src/execution Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ use super::catalogs::{catalog::DFCatalog, metastore::DFMetastore};
60
60
use super :: datafusion:: context_provider:: ExtendedSqlToRel ;
61
61
use super :: error:: { self as ex_error, ExecutionError , ExecutionResult } ;
62
62
use super :: session:: UserSession ;
63
- use super :: utils:: NormalizedIdent ;
63
+ use super :: utils:: { is_logical_plan_effectively_empty , NormalizedIdent } ;
64
64
use crate :: execution:: datafusion:: visitors:: { functions_rewriter, json_element} ;
65
65
use tracing_attributes:: instrument;
66
66
@@ -463,7 +463,7 @@ impl UserQuery {
463
463
..
464
464
} ) ) = plan
465
465
{
466
- if matches ! ( * input, LogicalPlan :: EmptyRelation ( _ ) ) {
466
+ if is_logical_plan_effectively_empty ( & input) {
467
467
return created_entity_response ( ) ;
468
468
}
469
469
let insert_plan = LogicalPlan :: Dml ( DmlStatement :: new (
@@ -814,7 +814,7 @@ impl UserQuery {
814
814
}
815
815
}
816
816
let select_query =
817
- format ! ( "SELECT {values} FROM {source_query} JOIN {target_table} {target_alias} ON {on}{where_clause_str}" ) ;
817
+ format ! ( "SELECT {values} FROM {source_query} LEFT JOIN {target_table} {target_alias} ON {on}{where_clause_str}" ) ;
818
818
819
819
// Construct the INSERT statement
820
820
let insert_query = format ! ( "INSERT INTO {target_table} ({columns}) {select_query}" ) ;
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ use chrono::DateTime;
28
28
use datafusion:: arrow:: array:: ArrayRef ;
29
29
use datafusion:: arrow:: datatypes:: DataType ;
30
30
use datafusion:: common:: Result as DataFusionResult ;
31
+ use datafusion_common:: ScalarValue ;
32
+ use datafusion_expr:: { Expr , LogicalPlan } ;
31
33
use embucket_metastore:: SchemaIdent as MetastoreSchemaIdent ;
32
34
use embucket_metastore:: TableIdent as MetastoreTableIdent ;
33
35
use sqlparser:: ast:: { Ident , ObjectName } ;
@@ -55,6 +57,23 @@ pub enum DataSerializationFormat {
55
57
Json ,
56
58
}
57
59
60
+ #[ must_use]
61
+ pub fn is_logical_plan_effectively_empty ( plan : & LogicalPlan ) -> bool {
62
+ match plan {
63
+ LogicalPlan :: EmptyRelation ( e) => !e. produce_one_row ,
64
+ LogicalPlan :: Projection ( proj) => is_logical_plan_effectively_empty ( & proj. input ) ,
65
+ LogicalPlan :: SubqueryAlias ( alias) => is_logical_plan_effectively_empty ( & alias. input ) ,
66
+ LogicalPlan :: Filter ( filter) => {
67
+ let is_false_predicate = matches ! (
68
+ filter. predicate,
69
+ Expr :: Literal ( ScalarValue :: Boolean ( Some ( false ) ) )
70
+ ) ;
71
+ is_false_predicate || is_logical_plan_effectively_empty ( & filter. input )
72
+ }
73
+ _ => false ,
74
+ }
75
+ }
76
+
58
77
/*#[async_trait::async_trait]
59
78
pub trait S3ClientValidation: Send + Sync {
60
79
async fn get_aws_bucket_acl(
You can’t perform that action at this time.
0 commit comments