Skip to content

Conversation

@xudong963
Copy link
Member

Part of the #18868

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates execution Related to the execution crate labels Nov 27, 2025
panic!("Expected binary OR expression result");
}

Ok(())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for NOT(NOT(a) AND NOT(b)).
It should be simplified to a OR b but let's confirm.

//! This module provides optimizations for NOT expressions such as:
//! - Double negation elimination: NOT(NOT(expr)) -> expr
//! - NOT with binary comparisons: NOT(a = b) -> a != b
//! - NOT with IN expressions: NOT(a IN (list)) -> a NOT IN (list)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really supported ?
I don't see neither implementation nor tests for IN


fn f_up(&mut self, node: Self::Node) -> Result<Transformed<Self::Node>> {
// Apply NOT expression simplification first
let not_simplified = simplify_not_expr_recursive(&node, self.schema)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the variable is a bit confusing - not_simplified. It sounds like it is not simplified.
Maybe rename it to not_expr_simplified ?!

return Ok(Transformed::yes(lit(ScalarValue::Boolean(Some(!val)))));
}
if let ScalarValue::Boolean(None) = literal.value() {
return Ok(Transformed::yes(lit(ScalarValue::Boolean(None))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this return Transformed::yes ?
It returns the same value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is NOT(NULL) -> NULL. All is good!

if not_simplified.transformed {
// Recursively simplify the result
let further_simplified =
simplify_not_expr_recursive(&not_simplified.data, schema)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this could be a vector of an attack.
Someone may craft a query with many not(not(not(not(...)))) to cause a stack overflow due to the usage of recursion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execution Related to the execution crate physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants