darpan-14 opened a new pull request, #5235:
URL: https://github.com/apache/calcite/pull/5235

   ## Jira Link
   
   [CALCITE-7757](https://issues.apache.org/jira/browse/CALCITE-7757)
   
   ## Changes Proposed
   
   RelMdFunctionalDependency can currently expose unsound or incorrectly 
indexed dependencies, allowing AggregateRemoveDuplicateKeysRule to remove 
grouping keys that are still required.
   
   This change:
   
   - Corrects equality-derived functional dependencies for INNER, LEFT, and 
RIGHT joins, respecting the null-generating side of outer joins.
   - Preserves valid input functional dependencies through outer joins without 
incorrectly deriving the reverse dependency from the join equality.
   - Maps aggregate input group ordinals to aggregate output ordinals before 
publishing functional-dependency metadata.
   - Avoids equality-derived dependencies for FLOAT, REAL, DOUBLE, and INTERVAL 
types, including nested occurrences.
   - Avoids unsafe expression-derived grouping dependencies for those same 
types.
   - Adds a reusable SqlTypeUtil predicate traversal for scalar and nested 
types.
   - Adds regression coverage for each correctness case.
   
   A basic valid duplicate-key removal remains supported:
   
       SELECT t1.col1, t2.col3, COUNT(*)
       FROM t1
       JOIN t2 ON t1.col1 = t2.col3
       GROUP BY t1.col1, t2.col3;
   
   For this inner join, either equivalent equality key may be removed. The new 
safeguards prevent that reasoning from being applied where null generation, 
ordinal mapping, or non-reflexive type semantics make it unsound.
   
   ## Testing
   
   - ./gradlew :core:test --tests org.apache.calcite.sql.type.SqlTypeUtilTest 
--tests org.apache.calcite.test.AggregateRemoveDuplicateKeysRuleTest --tests 
org.apache.calcite.test.RelMetadataTest.testFunctionalDependency*
   - ./gradlew :core:checkstyleMain :core:checkstyleTest
   - git diff --check upstream/main...HEAD
   
   The focused test run completed 49 tests with 0 failures.


-- 
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]

Reply via email to