Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
de30cb0
create first test
sdf-jkl Nov 6, 2025
052ab95
year_literal_to_type_with_op function
sdf-jkl Nov 10, 2025
d9a4253
kinda works
sdf-jkl Nov 10, 2025
83bae02
getting_there
sdf-jkl Nov 17, 2025
eec27c1
Merge branch 'apache:main' into pre-image-support
sdf-jkl Nov 17, 2025
1e794c3
taplo format
sdf-jkl Nov 19, 2025
2ec0b9a
add op_swap test
sdf-jkl Nov 19, 2025
630f5c5
Fix comment
sdf-jkl Nov 19, 2025
fbcfb97
commented out attempt for inlist support
sdf-jkl Nov 19, 2025
2b54409
restructure the changes
sdf-jkl Nov 20, 2025
3260ee9
Update datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
sdf-jkl Nov 20, 2025
cdfc2f5
Merge branch 'main' into pre-image-support
sdf-jkl Nov 20, 2025
d011b51
Fix merge error
sdf-jkl Nov 20, 2025
cd390df
cargo fmt plus some fixes
sdf-jkl Nov 21, 2025
36bb529
Add sqllogictest
sdf-jkl Nov 21, 2025
7c4dd9c
Add other than year date_part tests
sdf-jkl Nov 21, 2025
cdb9cb6
Fix docs
sdf-jkl Nov 21, 2025
57ee667
cargo fmt
sdf-jkl Nov 21, 2025
bb50792
Cargo fmt + doc changes
sdf-jkl Nov 21, 2025
fa3b31c
Merge branch 'main' into pre-image-support
sdf-jkl Nov 21, 2025
729951b
Rewrite logic
sdf-jkl Dec 1, 2025
8b62a2d
Merge branch 'pre-image-support' of https://github.com/sdf-jkl/datafu…
sdf-jkl Dec 1, 2025
ab9b444
support IsDistinctFrom and IsNotDistinctFrom
sdf-jkl Dec 2, 2025
5286626
Update sqllogictests
sdf-jkl Dec 2, 2025
5106049
Remove commented out changes
sdf-jkl Dec 3, 2025
19fafd1
Merge branch 'main' into pre-image-support
sdf-jkl Dec 3, 2025
516e637
Merge branch 'main' into pre-image-support
sdf-jkl Dec 8, 2025
5899a3a
Merge branch 'main' into pre-image-support
sdf-jkl Dec 8, 2025
e1c358f
Implementing suggestions
sdf-jkl Dec 12, 2025
63761a1
Merge branch 'pre-image-support' of https://github.com/sdf-jkl/datafu…
sdf-jkl Dec 12, 2025
c79e937
fix ci
sdf-jkl Dec 12, 2025
0318c62
Merge branch 'main' of https://github.com/apache/datafusion into pre-…
sdf-jkl Dec 12, 2025
352b3ff
cargo fmt
sdf-jkl Dec 12, 2025
7dbdc00
Move tests to core/optimizer/tests
sdf-jkl Dec 15, 2025
19ba392
Merge branch 'main' of https://github.com/apache/datafusion into pre-…
sdf-jkl Dec 16, 2025
5456976
Merge branch 'main' of https://github.com/apache/datafusion into pre-…
sdf-jkl Dec 22, 2025
114eb50
Merge branch 'main' of https://github.com/apache/datafusion into pre-…
sdf-jkl Dec 23, 2025
130413d
Improve IsDistinctFrom, IsNotDistinctFrom logic and add unit tests fo…
sdf-jkl Dec 23, 2025
ae05293
Return sqllogictests + add unit tests
sdf-jkl Dec 23, 2025
bc91039
Merge branch 'main' into pre-image-support
sdf-jkl Jan 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions datafusion/optimizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ chrono = { workspace = true }
datafusion-common = { workspace = true, default-features = true }
datafusion-expr = { workspace = true }
datafusion-expr-common = { workspace = true }
datafusion-functions = { workspace = true }
Comment thread
sdf-jkl marked this conversation as resolved.
Outdated
datafusion-physical-expr = { workspace = true }
indexmap = { workspace = true }
itertools = { workspace = true }
Expand Down
38 changes: 37 additions & 1 deletion datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ use datafusion_physical_expr::{create_physical_expr, execution_props::ExecutionP

use super::inlist_simplifier::ShortenInListSimplifier;
use super::utils::*;
use crate::analyzer::type_coercion::TypeCoercionRewriter;
use crate::simplify_expressions::guarantees::GuaranteeRewriter;
use crate::simplify_expressions::regex::simplify_regex_expr;
use crate::simplify_expressions::unwrap_cast::{
Expand All @@ -58,6 +57,13 @@ use crate::simplify_expressions::unwrap_cast::{
unwrap_cast_in_comparison_for_binary,
};
use crate::simplify_expressions::SimplifyInfo;
use crate::{
analyzer::type_coercion::TypeCoercionRewriter,
simplify_expressions::unwrap_date_part::{
is_date_part_expr_and_support_unwrap_date_part_in_comparison_for_binary,
unwrap_date_part_in_comparison_for_binary,
},
};
use datafusion_expr_common::casts::try_cast_literal_to_type;
use indexmap::IndexSet;
use regex::Regex;
Expand Down Expand Up @@ -1956,6 +1962,36 @@ impl<S: SimplifyInfo> TreeNodeRewriter for Simplifier<'_, S> {
}))
}

// =======================================
Comment thread
sdf-jkl marked this conversation as resolved.
// unwrap_date_part_in_comparison
// =======================================
//
// For case:
// date_part(expr as data_type) op literal
Comment thread
sdf-jkl marked this conversation as resolved.
Outdated
Expr::BinaryExpr(BinaryExpr { left, op, right })
Comment thread
sdf-jkl marked this conversation as resolved.
if is_date_part_expr_and_support_unwrap_date_part_in_comparison_for_binary(
info, &left, op, &right,
) && op.supports_propagation() =>
Comment thread
sdf-jkl marked this conversation as resolved.
Outdated
{
unwrap_date_part_in_comparison_for_binary(info, *left, *right, op)?
}
Comment thread
sdf-jkl marked this conversation as resolved.
// literal op date_part(literal, expression)
// -->
// date_part(literal, expression) op_swap literal
Expr::BinaryExpr(BinaryExpr { left, op, right })
if is_date_part_expr_and_support_unwrap_date_part_in_comparison_for_binary(
info, &right, op, &left,
) && op.supports_propagation()
&& op.swap().is_some() =>
{
unwrap_date_part_in_comparison_for_binary(
info,
*right,
*left,
op.swap().unwrap(),
)?
}

// no additional rewrites possible
expr => Transformed::no(expr),
})
Expand Down
1 change: 1 addition & 0 deletions datafusion/optimizer/src/simplify_expressions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod regex;
pub mod simplify_exprs;
mod simplify_predicates;
mod unwrap_cast;
mod unwrap_date_part;
mod utils;

// backwards compatibility
Expand Down
Loading
Loading