Skip to content

Commit

Permalink
TEIID-5459 adding docs for ranking and updating the grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 2, 2018
1 parent 111d598 commit 368038e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions admin/System_Properties.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ WARNING: Strings are always fully held in memory. Do not set this value too high
|Set to false to always generate OpenTracing information even if no Span is active.
|true

|_org.teiid.longRanks_
|Set to true to have the ranking functions RANK, DENSE_RANK, and ROW_NUMBER return long instead of integer.
|false

|===


Expand Down
2 changes: 1 addition & 1 deletion client-dev/OData4_Support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@ Since OData schema model is not a relational schema model, Teiid uses the follow

Teiid by design does not define any "embedded" ComplexType in the EntityType.

Since OData access is more key based, it is * MANDATORY* that every table Teiid exposes through OData must have a PK or at least one UNIQUE key. A table which does not either of these will be dropeed out of the $metadata
Since OData access is more key based, it is *MANDATORY* that every table Teiid exposes through OData must have a PK or at least one UNIQUE key. A table which does not either of these will be dropeed out of the $metadata
33 changes: 27 additions & 6 deletions reference/BNF_for_SQL_Grammar.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
|<<grantOption,Create GRANT>>

|[[token_GROUP]]_GROUP_
|<<groupBy,group by clause>>
|<<function,function>>, <<groupBy,group by clause>>

|[[token_HAVING]]_HAVING_
|<<having,having clause>>
Expand Down Expand Up @@ -518,6 +518,9 @@
|[[token_WITH]]_WITH_
|<<assignStatement,assignment statement>>, <<createRole,create role >>, <<importDatabase,Import another Database>>, <<queryExpression,query expression>>, <<readWith,with role>>, <<sqlStatement,data statement>>

|[[token_WITHIN]]_WITHIN_
|<<function,function>>

|[[token_WITHOUT]]_WITHOUT_
|<<assignStatement,assignment statement>>, <<sqlStatement,data statement>>

Expand Down Expand Up @@ -618,6 +621,9 @@
|[[token_COUNT]]_COUNT_
|<<aggregateSymbol,standard aggregate function>>, <<nonReserved,non-reserved identifier>>

|[[token_COUNT_BIG]]_COUNT_BIG_
|<<aggregateSymbol,standard aggregate function>>, <<nonReserved,non-reserved identifier>>

|[[token_CURRENT]]_CURRENT_
|<<nonReserved,non-reserved identifier>>, <<windowFrameBound,window frame bound>>

Expand Down Expand Up @@ -672,6 +678,9 @@
|[[token_FOLLOWING]]_FOLLOWING_
|<<nonReserved,non-reserved identifier>>, <<windowFrameBound,window frame bound>>

|[[token_GEOGRAPHY]]_GEOGRAPHY_
|<<nonReserved,non-reserved identifier>>, <<parseDataTypePrimary,simple data type>>

|[[token_GEOMETRY]]_GEOMETRY_
|<<nonReserved,non-reserved identifier>>, <<parseDataTypePrimary,simple data type>>

Expand Down Expand Up @@ -702,6 +711,9 @@
|[[token_LAST]]_LAST_
|<<nonReserved,non-reserved identifier>>, <<sortSpecification,sort specification>>

|[[token_LISTAGG]]_LISTAGG_
|<<function,function>>, <<nonReserved,non-reserved identifier>>

|[[token_MASK]]_MASK_
|<<grantOption,Create GRANT>>, <<nonReserved,non-reserved identifier>>, <<revokeGrantOption,Revoke GRANT>>

Expand Down Expand Up @@ -928,9 +940,8 @@
|SYMETRIC|SYSTEM|SYSTEM_USER
|TIMEZONE_HOUR|TIMEZONE_MINUTE|TRANSLATION
|TREAT|VALUE|VARYING
|WHENEVER|WINDOW|WITHIN
|XMLBINARY|XMLDOCUMENT|XMLITERATE
|XMLVALIDATE
|WHENEVER|WINDOW|XMLBINARY
|XMLDOCUMENT|XMLITERATE|XMLVALIDATE
|===

== Tokens
Expand Down Expand Up @@ -1742,6 +1753,8 @@ Example:

* <<token_COUNT,COUNT>>

* <<token_COUNT_BIG,COUNT_BIG>>

* <<token_ROW_NUMBER,ROW_NUMBER>>

* <<token_RANK,RANK>>
Expand Down Expand Up @@ -1932,6 +1945,10 @@ Example:

* <<token_FOLLOWING,FOLLOWING>>

* <<token_LISTAGG,LISTAGG>>

* <<token_GEOGRAPHY,GEOGRAPHY>>


Allows non-reserved keywords to be parsed as identifiers

Expand Down Expand Up @@ -2906,9 +2923,9 @@ TEXTAGG (col1 as t1, col2 as t2 DELIMITER ',' HEADER)

=== [[aggregateSymbol]]_<<usage_aggregateSymbol, standard aggregate function>>_ ::=

* ( <<token_COUNT,COUNT>> <<<token_LPAREN,lparen>>> <<<token_STAR,star>>> <<<token_RPAREN,rparen>>> )
* ( ( <<token_COUNT,COUNT>> | <<token_COUNT_BIG,COUNT_BIG>> ) <<<token_LPAREN,lparen>>> <<<token_STAR,star>>> <<<token_RPAREN,rparen>>> )

* ( ( <<token_COUNT,COUNT>> | <<token_SUM,SUM>> | <<token_AVG,AVG>> | <<token_MIN,MIN>> | <<token_MAX,MAX>> | <<token_EVERY,EVERY>> | <<token_STDDEV_POP,STDDEV_POP>> | <<token_STDDEV_SAMP,STDDEV_SAMP>> | <<token_VAR_SAMP,VAR_SAMP>> | <<token_VAR_POP,VAR_POP>> | <<token_SOME,SOME>> | <<token_ANY,ANY>> ) <<<token_LPAREN,lparen>>> ( <<token_DISTINCT,DISTINCT>> | <<token_ALL,ALL>> )? <<<expression,expression>>> <<<token_RPAREN,rparen>>> )
* ( ( <<token_COUNT,COUNT>> | <<token_COUNT_BIG,COUNT_BIG>> | <<token_SUM,SUM>> | <<token_AVG,AVG>> | <<token_MIN,MIN>> | <<token_MAX,MAX>> | <<token_EVERY,EVERY>> | <<token_STDDEV_POP,STDDEV_POP>> | <<token_STDDEV_SAMP,STDDEV_SAMP>> | <<token_VAR_SAMP,VAR_SAMP>> | <<token_VAR_POP,VAR_POP>> | <<token_SOME,SOME>> | <<token_ANY,ANY>> ) <<<token_LPAREN,lparen>>> ( <<token_DISTINCT,DISTINCT>> | <<token_ALL,ALL>> )? <<<expression,expression>>> <<<token_RPAREN,rparen>>> )


A standard aggregate function.
Expand Down Expand Up @@ -4178,6 +4195,8 @@ CASE WHEN x = 'a' THEN 1 WHEN y = 'b' THEN 2
* ( <<token_POSITION,POSITION>> <<<token_LPAREN,lparen>>> <<<commonValueExpression,common value expression>>> <<token_IN,IN>> <<<commonValueExpression,common value expression>>> <<<token_RPAREN,rparen>>> )
* ( <<token_LISTAGG,LISTAGG>> <<<token_LPAREN,lparen>>> <<<expression,expression>>> ( <<<token_COMMA,comma>>> <<<stringVal,string>>> )? <<<token_RPAREN,rparen>>> <<token_WITHIN,WITHIN>> <<token_GROUP,GROUP>> <<<token_LPAREN,lparen>>> <<<orderby,order by clause>>> <<<token_RPAREN,rparen>>> )
* ( <<<id,identifier>>> <<<token_LPAREN,lparen>>> ( <<token_ALL,ALL>> | <<token_DISTINCT,DISTINCT>> )? ( <<<expressionList,expression list>>> )? ( <<<orderby,order by clause>>> )? <<<token_RPAREN,rparen>>> ( <<<filterClause,filter clause>>> )? )
* ( <<token_CURRENT_DATE,CURRENT_DATE>> ( <<<token_LPAREN,lparen>>> <<<token_RPAREN,rparen>>> )? )
Expand Down Expand Up @@ -4416,6 +4435,8 @@ NO DEFAULT
* <<token_GEOMETRY,GEOMETRY>>
* <<token_GEOGRAPHY,GEOGRAPHY>>
* <<token_XML,XML>>
Expand Down
4 changes: 3 additions & 1 deletion reference/Expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Teiid supports the following aggregate functions:

* COUNT(*) – count the number of values (including nulls and duplicates) in a group. Returns an integer - an exception will be thrown if a larger count is computed.
* COUNT(x) – count the number of values (excluding nulls) in a group. Returns an integer - an exception will be thrown if a larger count is computed.
* COUNT_BIG(*) – count the number of values (including nulls and duplicates) in a group. Returns a long - an exception will be thrown if a larger count is computed.
* COUNT_BIG(x) – count the number of values (excluding nulls) in a group. Returns a long - an exception will be thrown if a larger count is computed.
* SUM(x) – sum of the values (excluding nulls) in a group
* AVG(x) – average of the values (excluding nulls) in a group
* MIN(x) – minimum value in a group (excluding null)
Expand Down Expand Up @@ -274,7 +276,7 @@ Ranking Functions:
* PERCENT_RANK() – Computed as (RANK - 1) / ( RC - 1) where RC is the total row count of the partition.
* CUME_DIST() – Computed as the PR / RC where PR is the rank of the row including peers and RC is the total row count of the partition.

All values are integers - an exception will be thrown if a larger value is needed.
By default all values are integers - an exception will be thrown if a larger value is needed. Use the system org.teiid.longRanks to have RANK, DENSE_RANK, and ROW_NUMBER return long values instead.

Value Functions:

Expand Down

0 comments on commit 368038e

Please sign in to comment.