jayzhan211 commented on code in PR #13134:
URL: https://github.com/apache/datafusion/pull/13134#discussion_r1819112939
##########
datafusion/optimizer/src/decorrelate_predicate_subquery.rs:
##########
@@ -296,37 +287,26 @@ fn build_join_top(
///
/// ```text
/// Projection: t1.id
-/// Filter: t1.id < 0 OR __correlated_sq_1.__exists IS NOT NULL
-/// Left Join: Filter: t1.id = __correlated_sq_1.id
+/// Filter: t1.id < 0 OR __correlated_sq_1.mark
+/// LeftMark Join: Filter: t1.id = __correlated_sq_1.id
/// TableScan: t1
/// SubqueryAlias: __correlated_sq_1
-/// Projection: t2.id, true as __exists
+/// Projection: t2.id
/// TableScan: t2
-fn existence_join(
+fn mark_join(
left: &LogicalPlan,
subquery: Arc<LogicalPlan>,
in_predicate_opt: Option<Expr>,
negated: bool,
alias_generator: &Arc<AliasGenerator>,
) -> Result<Option<(LogicalPlan, Expr)>> {
- // Add non nullable column to emulate existence join
- let always_true_expr = lit(true).alias("__exists");
- let cols = chain(
- subquery.schema().columns().into_iter().map(Expr::Column),
- iter::once(always_true_expr),
- );
- let subquery = LogicalPlanBuilder::from(subquery).project(cols)?.build()?;
let alias = alias_generator.next("__correlated_sq");
- let exists_col = Expr::Column(Column::new(Some(alias.clone()),
"__exists"));
- let exists_expr = if negated {
- exists_col.is_null()
- } else {
- exists_col.is_not_null()
- };
+ let exists_col = Expr::Column(Column::new(Some(alias.clone()), "mark"));
Review Comment:
Also here.
It seems the column has prefix `__` for `__exists` too. I think what
@jonahgao said makes sense. At least is more consistent with internal plan/expr
naming
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]