Обсуждение: Aggregate expression syntax

Поиск
Список
Период
Сортировка

Aggregate expression syntax

От
Thom Brown
Дата:
Hi all,

Looking at the syntax for aggregate expressions in the docs, it seems the first three forms could perhaps be merged since the ALL and DISTINCT keywords are effectively optional.

Currently:

aggregate_name (expression [ , ... ] [ order_by_clause ] ) [ FILTER ( WHERE filter_clause ) ]
aggregate_name (ALL expression [ , ... ] [ order_by_clause ] ) [ FILTER ( WHERE filter_clause ) ]
aggregate_name (DISTINCT expression [ , ... ] [ order_by_clause ] ) [ FILTER ( WHERE filter_clause ) ]

Proposed:

aggregate_name ( [ ALL | DISTINCT ] expression [ , ... ] [ order_by_clause ] ) [ FILTER ( WHERE filter_clause ) ]

I've also found a precedent for this on the SELECT statement page:

[ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]

Patch attached with the proposed change.

Opinions?

Thom
Вложения

Re: Aggregate expression syntax

От
Tom Lane
Дата:
Thom Brown <thom@linux.com> writes:
> Looking at the syntax for aggregate expressions in the docs, it seems the
> first three forms could perhaps be merged since the ALL and DISTINCT
> keywords are effectively optional.

Dunno, just seems harder to read to me...

            regards, tom lane


--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


Re: Aggregate expression syntax

От
David G Johnston
Дата:
Tom Lane-2 wrote
> Thom Brown <

> thom@

> > writes:
>> Looking at the syntax for aggregate expressions in the docs, it seems the
>> first three forms could perhaps be merged since the ALL and DISTINCT
>> keywords are effectively optional.
>
> Dunno, just seems harder to read to me...

I'm generally for making the syntax part more succinct and addressing
learning concerns with examples.  The extra noise that needs to be filtered
out when trying to figure out why different structures exist makes it
difficult to read too.

That said, having at least a bare-minimum expression would be helpful:

aggregate_name ( expression )

And now decide whether to have a combined syntax block or keep building
things up like:

aggregate_name ( [ ALL | DISTINCT ] expression [ , ... ] [ order_by_clause]
)
aggregate_name ( argument_clause ) [ FILTER ( WHERE [ filter_clause ] ) ]

argument_clause := " [ ALL | DISTINCT ] expression [ , ... ] [
order_by_clause ] "

If we are going to repeat long and complex parts of the syntax naming them
will make reading subsequent syntax expressions easier and provide semantic
meaning to the reader.  The existing forms, while correct, are repetitive
and that is what is being targeted but combining them into a single syntax
block.  But if that is too hard to read and understand then maybe some other
means of simplification, like my example above, would work better.

David J.







--
View this message in context: http://postgresql.nabble.com/Aggregate-expression-syntax-tp5834726p5834768.html
Sent from the PostgreSQL - docs mailing list archive at Nabble.com.


--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


Re: [DOCS] Aggregate expression syntax

От
Tom Lane
Дата:
Thom Brown <thom@linux.com> writes:
> Looking at the syntax for aggregate expressions in the docs, it seems the
> first three forms could perhaps be merged since the ALL and DISTINCT
> keywords are effectively optional.

Dunno, just seems harder to read to me...

            regards, tom lane


--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


Re: [DOCS] Aggregate expression syntax

От
David G Johnston
Дата:
Tom Lane-2 wrote
> Thom Brown <

> thom@

> > writes:
>> Looking at the syntax for aggregate expressions in the docs, it seems the
>> first three forms could perhaps be merged since the ALL and DISTINCT
>> keywords are effectively optional.
>
> Dunno, just seems harder to read to me...

I'm generally for making the syntax part more succinct and addressing
learning concerns with examples.  The extra noise that needs to be filtered
out when trying to figure out why different structures exist makes it
difficult to read too.

That said, having at least a bare-minimum expression would be helpful:

aggregate_name ( expression )

And now decide whether to have a combined syntax block or keep building
things up like:

aggregate_name ( [ ALL | DISTINCT ] expression [ , ... ] [ order_by_clause]
)
aggregate_name ( argument_clause ) [ FILTER ( WHERE [ filter_clause ] ) ]

argument_clause := " [ ALL | DISTINCT ] expression [ , ... ] [
order_by_clause ] "

If we are going to repeat long and complex parts of the syntax naming them
will make reading subsequent syntax expressions easier and provide semantic
meaning to the reader.  The existing forms, while correct, are repetitive
and that is what is being targeted but combining them into a single syntax
block.  But if that is too hard to read and understand then maybe some other
means of simplification, like my example above, would work better.

David J.







--
View this message in context: http://postgresql.nabble.com/Aggregate-expression-syntax-tp5834726p5834768.html
Sent from the PostgreSQL - docs mailing list archive at Nabble.com.


--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs