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

Sorting semantics #66

Open
plcplc opened this issue Nov 14, 2023 · 1 comment
Open

Sorting semantics #66

plcplc opened this issue Nov 14, 2023 · 1 comment

Comments

@plcplc
Copy link
Contributor

plcplc commented Nov 14, 2023

The spec for ordering by counting and column aggregations currently read (emphasis mine):

Type star_count_aggregate

An ordering of type star_count_aggregate orders rows by a count of rows in some related collection. If the respective counts are incomparable, the ordering should continue to the next OrderByElement.

and

Type single_count_aggregate

An ordering of type single_count_aggregate orders rows by an aggregate computed over rows in some related collection. If the respective aggregates are incomparable, the ordering should continue to the next OrderByElement.

What is the actual meaning of the highlighted phrases above, and what part of the engine/ndc/db complex is supposed to make that judgement?

How can a count be incomparable?

While the result of an arbitrary aggregation could conceivably be incomparable, it seems like a tall order to ask the ndc to make that judgement, and if the ndc just assumes comparability and passes the compiled query to the database it will likely just fail rather than be irrelevant to the resulting ordering as the spec suggests.

If it's meant to be an optional behavior I think it'd be nice to mark it more clearly as such (like how the W3C specifications typographically emphasise when the words "SHOULD", "MUST" etc. have a normative meaning, originally from https://www.ietf.org/rfc/rfc2119.txt I believe)

@paf31
Copy link
Collaborator

paf31 commented Nov 14, 2023

"incomparable" should maybe say "equal or incomparable". It says incomparable because an OrderByElement might describe a partial ordering in which two elements might not be equal, but might not be less-or-greater-than either. The point is that an array of OrderByElements should use the first, then the second only if the first fails to yield a distinction in ordering between two elements, and so on.

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

No branches or pull requests

2 participants