kumarUjjawal commented on code in PR #27544:
URL: https://github.com/apache/datafusion/pull/27544#discussion_r4624535553
##########
datafusion/optimizer/src/rewrite_set_comparison.rs:
##########
@@ -105,26 +105,28 @@ fn build_set_comparison_subquery(
Box::new(right_expr),
));
- let true_exists =
- exists_subquery(&subquery,
Expr::IsTrue(Box::new(comparison.clone())))?;
let null_exists =
exists_subquery(&subquery,
Expr::IsNull(Box::new(comparison.clone())))?;
let result_expr = match quantifier {
Review Comment:
With `true_exists` moved into the `Any` arm, the `Any` and `All` arms are
now two near-copies of a 14-line CASE builder that differ only in
`IsTrue`/`IsFalse` and which of true/false is the THEN or ELSE value.
##########
datafusion/optimizer/src/analyzer/resolve_grouping_function.rs:
##########
@@ -248,8 +248,7 @@ fn grouping_function_on_id(
// Mask the ordinal bits above position `n` so only the semantic
bitmask is visible.
// checked_shl returns None when n >= 64 (all bits are semantic),
mapping to u64::MAX.
let semantic_mask: u64 = 1u64.checked_shl(n as u32).map_or(u64::MAX,
|m| m - 1);
- let masked_id =
- bitwise_and(grouping_id_column.clone(), literal(semantic_mask as
usize));
+ let masked_id = bitwise_and(grouping_id_column, literal(semantic_mask
as usize));
Review Comment:
In the function this PR edits, `semantic_mask as usize` (and `literal(1 <<
group_by_idx)` at line 261) goes through `usize`, so on 32-bit targets (wasm32)
a mask for more than 32 grouping columns is cut to 32 bits before it becomes a
UInt64 literal.
##########
datafusion/optimizer/src/decorrelate_predicate_subquery.rs:
##########
Review Comment:
https://github.com/apache/datafusion/blob/eb6ed4d3e77c1ad72f99920b6098cfdc9e90e552/datafusion/optimizer/src/decorrelate_predicate_subquery.rs#L1299
A redundant clone of the HAVING expression is still there:
`build_join_with_count_bug` takes `Option<&Expr>` and deep-clones it at line
1303 (`f.clone().transform_up(...)`), but its only caller (line 973,
`pull_up.pull_up_having_expr.as_ref()`) owns `pull_up` and returns right after
the call, so it could move the expression in.
##########
datafusion/optimizer/src/rewrite_set_comparison.rs:
##########
Review Comment:
https://github.com/apache/datafusion/blob/eb6ed4d3e77c1ad72f99920b6098cfdc9e90e552/datafusion/optimizer/src/rewrite_set_comparison.rs#L147
`exists_subquery` always clones the subquery's root `LogicalPlan` node and
`spans`, even for the last of the two EXISTS subqueries, where the owned
`subquery` could be moved in (`Arc::unwrap_or_clone`).
--
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]