Skip to content

Conversation

@xiedeyantu
Copy link
Member

See CALCITE-7397

Although the issue in Jira has been resolved, this case still generates a nested loop join (mark join), resulting in a new error, albeit a new one, because we haven't yet implemented nested loop join for left_mark join. However, I'll post this issue and its fix here for now, so we can verify it once nested loop join is implemented.

!plan
!}

# [CALCITE-7397] TopDownGeneralDecorrelator can cause nullable property mismatches
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed from the error message that after the subquery was removed the condition of left mark join was FALSE, I think this is the root cause. When the IN subquery is converted to a left mark join, its join condition originally looks like CAST(NULL AS int) = $x. However, inside builder.join the join condition is simplified using an “UNKNOWN AS FALSE” policy. But for a mark join, the marker is a three-valued-logic boolean, so strictly speaking the join condition should be simplified to NULL::BOOLEAN, so maybe we should use “UNKNOWN AS UNKNOWN ” policy for lelf mark join.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for pointing out the root cause, which is more correct than my logic for calling convert later. I tried modifying it according to your suggestion, and I'll see if it meets your requirements.

Copy link
Member Author

@xiedeyantu xiedeyantu Jan 26, 2026

Choose a reason for hiding this comment

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

Quidem cannot be executed at the moment, so I used a different method and added a test in RelOptRulesTest, which also verified the problem.

@xiedeyantu xiedeyantu force-pushed the CALCITE-7397 branch 4 times, most recently from 205e604 to a0e5873 Compare January 26, 2026 12:28
@silundong
Copy link
Contributor

silundong commented Jan 26, 2026

The code looks great. I have a small suggestion for the title. How about changing it to "Error in simplifying join condition when creating left mark join"? This better reflects the root cause.

@xiedeyantu xiedeyantu changed the title [CALCITE-7397] TopDownGeneralDecorrelator can cause nullable property mismatches [CALCITE-7397] TError in simplifying join condition when creating left mark join Jan 26, 2026
@xiedeyantu xiedeyantu changed the title [CALCITE-7397] TError in simplifying join condition when creating left mark join [CALCITE-7397] Error in simplifying join condition when creating LEFT MARK JOIN Jan 26, 2026
@xiedeyantu
Copy link
Member Author

The code looks great. I have a small suggestion for the title. How about changing it to "Error in simplifying join condition when creating left mark join"? This better reflects the root cause.

Done!

@sonarqubecloud
Copy link

@silundong silundong merged commit 41774e2 into apache:main Jan 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants