Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-10 Thread via GitHub
ding-young commented on code in PR #15589: URL: https://github.com/apache/datafusion/pull/15589#discussion_r2032229805 ## datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs: ## @@ -2152,6 +2169,17 @@ mod tests { } } +#[test] +fn test_simplif

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-09 Thread via GitHub
alamb commented on code in PR #15589: URL: https://github.com/apache/datafusion/pull/15589#discussion_r2036171313 ## datafusion/sqllogictest/test_files/array.slt: ## @@ -6140,21 +6140,19 @@ logical_plan 02)--Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] 03)SubqueryAlia

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-07 Thread via GitHub
kosiew commented on code in PR #15589: URL: https://github.com/apache/datafusion/pull/15589#discussion_r2030907522 ## datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs: ## @@ -760,6 +760,23 @@ impl TreeNodeRewriter for Simplifier<'_, S> { Non

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-07 Thread via GitHub
kosiew commented on code in PR #15589: URL: https://github.com/apache/datafusion/pull/15589#discussion_r2030914487 ## datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs: ## @@ -2152,6 +2169,17 @@ mod tests { } } +#[test] +fn test_simplify_eq

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-07 Thread via GitHub
berkaysynnada commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2782457130 > I wrote a simple criterion bench (https://github.com/ding-young/datafusion/blob/simplify-trivial-eq-bench/datafusion/core/benches/simplify_trivial_eq.rs) and the result is as

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-07 Thread via GitHub
ding-young commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2782347240 I wrote a simple criterion bench (https://github.com/ding-young/datafusion/blob/simplify-trivial-eq-bench/datafusion/core/benches/simplify_trivial_eq.rs) and the result is as foll

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-06 Thread via GitHub
alamb commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2781429451 We could also use a CASE ```sql CASE x IS NOT NULL THEN true ELSE null END ``` -- This is an automated message from the Apache Git Service. To respond to the message, pl

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-06 Thread via GitHub
alamb commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2781429711 I expect this to make a large performance difference when x is a string type (as string comparisons are fairly expensive) Thank you for this PR @ding-young and the great reviews

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-06 Thread via GitHub
berkaysynnada commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2781400999 > About the performance, I'm not 100% sure whether this rule worth the change, but I made this change because `IS NOT NULL OR NULL` was a bit better than actual comparision.

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-06 Thread via GitHub
ding-young commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2781281225 @2010YOUY01 Instead of applying transformation on filter expression, I adjusted the rule to transform x=x into `x IS NOT NULL OR NULL`. This preserves the behavior where NULL = NU

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-05 Thread via GitHub
ding-young commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2780386375 > This optimizer transformation doesn't look right for projected columns like > > ``` > create table t1(v1 int); > insert into t1 values (null); > > select v1=v1

Re: [PR] Enhance: simplify x=x [datafusion]

2025-04-05 Thread via GitHub
2010YOUY01 commented on PR #15589: URL: https://github.com/apache/datafusion/pull/15589#issuecomment-2780385095 This optimizer transformation doesn't look right for projected columns like ``` create table t1(v1 int); insert into t1 values (null); select v1=v1 from t1; -- Sh