Repository navigation
Introduce Quantifier.AtMostOne as the base class of Quantifier.Existential - #4657
Merged
Merged
Conversation
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
2 times, most recently
from
October 5, 2026 15:28
d34c722 to
2f60654
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 9, 2026 16:12
2f60654 to
1ed01e6
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
3 times, most recently
from
October 12, 2026 09:51
0f3b2f7 to
0f378d0
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 13, 2026 12:30
0f378d0 to
03511fe
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 19, 2026 13:43
03511fe to
f40fafb
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 21, 2026 14:01
f40fafb to
be0f4fb
Compare
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
2 times, most recently
from
October 26, 2026 16:16
12d0db5 to
57514ff
Compare
normen662
requested changes
Oct 27, 2026
normen662
left a comment
Contributor
There was a problem hiding this comment.
Hi, I know this a bigger change in terms of semantic effect this can have.
- Terminology is unclear. What is a scalar quantifier called that is not existential?
- Why is the
Scalarclass abstract. I thought we wanted to use that class as true scalar quantifiers. Maybe that's part of a different PR but it is confusing to me. Even if theScalarclass is made to be not abstract it feels weird to me. I guess what I am suggesting is the classical inverted Y-shape instead: Have an abstractQuantifier.AtMostOne(name TBD), subclassed by non-abstractQuantifier.ScalarandQuantifier.Existential. I think that would give you better reasoning capabilities and less clunkiness throughout the planner. It also aligns better to the casual reader of this code since everyone knows what scalar subqueries are and existential subqueries are NOT scalar subqueries. - Current
instanceofchecks: I tried to be as precise as I could in my individual comments. My advice: Keep the matching code stick toExistential, be careful with the rest. I am not confident I caught all problems. :-(. I think I will need to go through all the changes that you did swivel over toScalarto make sure they work. I am also worried about testing that stuff. I would actually suggest to keep most of the changes to the oldExistentialunless we know exactly what happens AND that we have a test for it. Then, when the other scalar subquery stuff hits, you can broaden the field. - Negative space. I don't think we did this in the past and if we did this, then only maybe in a very few places: I am worried that there are places where we say do something to every quantifier that is not an existential. Now it's in the stars if that can then also be widened to all scalars. I think you should use your AI of choice to figure out if that's done anywhere and react if needed.
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 28, 2026 15:58
57514ff to
9dad1e5
Compare
Quantifier.ExistentialQuantifier.AtMostOne as the base class of Quantifier.Existential
…stential` * Introduce `Quantifier.AtMostOne`, which serves as an abstract sealed base class of quantifiers that flow exactly one item of the sub-graph (or `NULL` if it is empty). For now, `Quantifier.Existential` is its only subclass. * Move the behavior that is shared by such quantifiers (the nullable flowed type, the flowed columns, and the pull-up of a max match map) from `Quantifier.Existential` into `Quantifier.AtMostOne`. * Make `CardinalitiesProperty`, `DistinctRecordsProperty`, `OrderingProperty` and `StoredRecordProperty` check for `Quantifier.AtMostOne` instead of `Existential`. These properties hold for every quantifier that flows exactly one item. * Add tests for `Quantifier.Existential` and `Quantifier.AtMostOne`, and for the cardinality of a `SELECT` with an existential quantifier. In a subsequent PR, a second subclass will be added in order to introduce support for scalar subqueries in SQL.
robert-brunel
force-pushed
the
apple/robert-brunel/scalar-subqueries-0
branch
from
October 28, 2026 17:53
9dad1e5 to
d207de8
Compare
normen662
approved these changes
Oct 28, 2026
* In `DistinctRecordsProperty`, remove the check for an `AtMostOne` quantifier from `DistinctRecordsVisitor.distinctRecordsFromChildren()`, which is only called for comparator and selector plans, and their quantifiers are always physical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quantifier.AtMostOne, which serves as an abstract sealed base class of quantifiers that flow exactly one item of the sub-graph (orNULLif it is empty). For now,Quantifier.Existentialis its only subclass.Quantifier.ExistentialintoQuantifier.AtMostOne.CardinalitiesProperty,DistinctRecordsProperty,OrderingPropertyandStoredRecordPropertycheck forQuantifier.AtMostOneinstead ofExistential. These properties hold for every quantifier that flows exactly one item.Quantifier.ExistentialandQuantifier.AtMostOne, and for the cardinality of aSELECTwith an existential quantifier.In a subsequent PR, a second subclass will be added in order to introduce support for scalar subqueries in SQL.