Repository navigation
feat(analysis): accept an aliased sole COUNT(*) projection - #32
Merged
Merged
Conversation
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.
Summary
A read can now count its matching rows. When
COUNT(*)with an alias is the only projection, the query generates a<QueryName>Resultrecord with one non-nullLongcomponent named after the alias. Before this change, everyCOUNT(*)failed withUnsupported SELECT expression: Function, so a common CRUD count query could not be compiled.Changes
COUNT(*)with an alias written with or withoutAS. It resolves as a non-nullBIGINTcolumn, which generates aLongcomponent that is0when no row matches.COUNT(*)without an alias fails withCOUNT(*) requires a result alias, such as COUNT(*) AS total.COUNT(*)beside another projection item fails withCOUNT(*) must be the only SELECT item.:onecount, checks that its component is typedLong, and checks the result for matching and non-matching input.Scope and non-goals
COUNT(column),COUNT(DISTINCT ...),COUNT(t.*), a qualifiedpg_catalog.count(*), theFILTERandOVERforms, and every other function or aggregate still fail with the existing unsupported-expression diagnostic.GROUP BYandHAVINGare still not analyzed, andRETURNINGis unchanged.BIGINTresult column already generates aLongcomponent.