You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Benchao Li (Jira)" <ji...@apache.org> on 2023/08/13 14:53:00 UTC
[jira] [Closed] (CALCITE-5925) LoptOptimizeJoinRule has when judging if SelfJoinKeys are unique
[ https://issues.apache.org/jira/browse/CALCITE-5925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benchao Li closed CALCITE-5925.
-------------------------------
Resolution: Duplicate
> LoptOptimizeJoinRule has when judging if SelfJoinKeys are unique
> -----------------------------------------------------------------
>
> Key: CALCITE-5925
> URL: https://issues.apache.org/jira/browse/CALCITE-5925
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.33.0, 1.34.0, 1.35.0
> Reporter: qiang.wang
> Priority: Minor
>
> There's wrong condition in function _areSelfJoinKeysUnique._
>
>
> {code:java}
> // Make sure each key on the left maps to the same simple column as the
> // corresponding key on the right
> for (IntPair pair : joinInfo.pairs()) {
> final RelColumnOrigin leftOrigin =
> mq.getColumnOrigin(leftRel, pair.source);
> if (leftOrigin == null || !leftOrigin.isDerived()) {
> return false;
> }
> final RelColumnOrigin rightOrigin =
> mq.getColumnOrigin(rightRel, pair.target);
> if (rightOrigin == null || !rightOrigin.isDerived()) {
> return false;
> }
> if (leftOrigin.getOriginColumnOrdinal()
> != rightOrigin.getOriginColumnOrdinal()) {
> return false;
> }
> } {code}
> The wrong conditions are '{_}if (leftOrigin == null || !leftOrigin.isDerived()){_}' and '{_}if (rightOrigin == null || !rightOrigin.isDerived()){_}'.
> This function wants to find out if the self-join keys are unique. so for each self-join key, find
> _leftOrigin_ and _rightOrigin_ first, then will return false if any of them is null. But why it returns false when any of them is not _Derived?_ I think exactly the opposite is right.
> I think this is a bug comes from CALCITE-4251
> Before that PR, this function will return false only when _leftOrigin_ or _rightOrigin_ is null, and the function _RelMetadataQuery#getColumnOrigin_ will return null if column is derived, so the logic is : 'this function will return null when _leftOrigin_ or _rightOrigin_ is null or is derived', but now is : 'this function will return null when _leftOrigin_ or _rightOrigin_ is null or is not derived'.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)