Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of OPTIONAL with empty or unconnected patterns #1847

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

RobinTF
Copy link
Collaborator

@RobinTF RobinTF commented Mar 3, 2025

Fixes #1761, by ensuring that the OPTIONAL clause will always return at least a single value, so the cartesian product will never be empty.

size_t NeutralOptional::getCostEstimate() {
// Cloning is expensive, so we estimate the cost as the cost of the child.
// Does not apply to the lazy case.
return std::max<size_t>(tree_->getCostEstimate(), 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if this is the right thing to do here.

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the comment about the cloning etc.
There also is nothing to clone here?
And like this, the operation is free, as the cost estimate always has to include the costs for the children.

Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (0daadaa) to head (1470743).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1847      +/-   ##
==========================================
+ Coverage   90.20%   90.24%   +0.03%     
==========================================
  Files         400      401       +1     
  Lines       38514    38616     +102     
  Branches     4319     4330      +11     
==========================================
+ Hits        34743    34850     +107     
+ Misses       2477     2473       -4     
+ Partials     1294     1293       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

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

Thank you very much,
I have some questions and suggestions.
Please start commenting your code (docstrings + non-obvious code parts)

size_t NeutralOptional::getCostEstimate() {
// Cloning is expensive, so we estimate the cost as the cost of the child.
// Does not apply to the lazy case.
return std::max<size_t>(tree_->getCostEstimate(), 1);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the comment about the cloning etc.
There also is nothing to clone here?
And like this, the operation is free, as the cost estimate always has to include the costs for the children.

@sparql-conformance
Copy link

Copy link

sonarqubecloud bot commented Mar 5, 2025

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.

Issue with multiple OPTIONALs and COALESCE
2 participants