JasonLi-cn commented on code in PR #13249:
URL: https://github.com/apache/datafusion/pull/13249#discussion_r1828713330


##########
datafusion/optimizer/src/utils.rs:
##########
@@ -129,52 +128,32 @@ pub fn log_plan(description: &str, plan: &LogicalPlan) {
 /// `c0 > 8` return true;
 /// `c0 IS NULL` return false.
 pub fn is_restrict_null_predicate<'a>(
+    input_schema: &DFSchema,
     predicate: Expr,
-    join_cols_of_predicate: impl IntoIterator<Item = &'a Column>,
+    cols_of_predicate: impl IntoIterator<Item = &'a Column>,
 ) -> Result<bool> {
     if matches!(predicate, Expr::Column(_)) {
         return Ok(true);
     }
 
-    static DUMMY_COL_NAME: &str = "?";
-    let schema = Schema::new(vec![Field::new(DUMMY_COL_NAME, DataType::Null, 
true)]);
-    let input_schema = DFSchema::try_from(schema.clone())?;
-    let column = new_null_array(&DataType::Null, 1);
-    let input_batch = RecordBatch::try_new(Arc::new(schema.clone()), 
vec![column])?;
     let execution_props = ExecutionProps::default();
-    let null_column = Column::from_name(DUMMY_COL_NAME);
+    let replace_columns = cols_of_predicate.into_iter().collect();
+    let replaced_predicate = replace_expr_with_null(predicate, 
&replace_columns)?;
+    let coerced_predicate = coerce(replaced_predicate, input_schema)?;

Review Comment:
   I removed the `coerce` function. But some Exprs that is restrict null 
predicate cannot be judged to be true. 
   
https://github.com/JasonLi-cn/arrow-datafusion/blob/3bb49de20476a12a0b0b42ae6869991a8d83cb7c/datafusion/optimizer/src/utils.rs#L263-L303
   
   But since these `cast`s are handled with `type_coercion`, they are also 
acceptable.
   
https://github.com/JasonLi-cn/arrow-datafusion/blob/fdc9f5974579ab6169c1577d8000c315df0219d7/datafusion/sqllogictest/test_files/joins.slt#L4321-L4337



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to