Skip to content

Commit

Permalink
Traduction du chapitre sur les fonctions de fenêtrage
Browse files Browse the repository at this point in the history
  • Loading branch information
gleu committed Oct 15, 2020
1 parent 015cadb commit a4a0479
Showing 1 changed file with 104 additions and 103 deletions.
207 changes: 104 additions & 103 deletions postgresql/func.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19748,45 +19748,47 @@ SELECT count(*) FROM sometable;
</sect1>

<sect1 id="functions-window">
<title>Window Functions</title>
<title>Fonctions de fenêtrage</title>

<indexterm zone="functions-window">
<primary>window function</primary>
<secondary>built-in</secondary>
<primary>fonction de fenêtrage</primary>
<secondary>native</secondary>
</indexterm>

<para>
<firstterm>Window functions</firstterm> provide the ability to perform
calculations across sets of rows that are related to the current query
row. See <xref linkend="tutorial-window"/> for an introduction to this
feature, and <xref linkend="syntax-window-functions"/> for syntax
details.
Les <firstterm>fonctions de fenêtrage</firstterm> fournissent des moyens
pour réaliser des calculs sur des ensembles de lignes relatives à la ligne
actuelle de la requête. Voir <xref linkend="tutorial-window"/> pour une
introduction à cette fonctionnalité, et <xref
linkend="syntax-window-functions"/> pour les détails sur la syntaxe.
</para>

<para>
The built-in window functions are listed in
<xref linkend="functions-window-table"/>. Note that these functions
<emphasis>must</emphasis> be invoked using window function syntax, i.e., an
<literal>OVER</literal> clause is required.
Les fonctions de fenêtrage natives sont montrées dans <xref
linkend="functions-window-table"/>. Notez que ces fonctions
<emphasis>doivent</emphasis> être appelées en utilisant la syntaxe des
fonctions de fénêtrage, c'est-à-dire en utilisant une clause
<literal>OVER</literal>.
</para>

<para>
In addition to these functions, any built-in or user-defined
ordinary aggregate (i.e., not ordered-set or hypothetical-set aggregates)
can be used as a window function; see
<xref linkend="functions-aggregate"/> for a list of the built-in aggregates.
Aggregate functions act as window functions only when an <literal>OVER</literal>
clause follows the call; otherwise they act as plain aggregates
and return a single row for the entire set.
En plus de ces fonctions, toute fonction d'agrégat standard native ou
définie par un utilisateur (donc pas les agrégats à ensemble ordonné ou à
ensemble hypothétique) peut être utilisée comme une fonction de
fenêtrage&nbsp;; voir <xref linkend="functions-aggregate"/> pour une liste
des agrégats natifs. Les fonctions d'agrégat agissent comme des fonctions
de fenêtrage quand une clause <literal>OVER</literal> est utilisée pour
l'appel&nbsp;; sinon elles agissent comme des agrégats standards et
renvoient une seule ligne pour un ensemble complet.
</para>

<table id="functions-window-table">
<title>General-Purpose Window Functions</title>
<title>Fonctions de fenêtrage à usage général</title>
<tgroup cols="1">
<thead>
<row>
<entry role="func_table_entry"><para role="func_signature">
Function
Fonction
</para>
<para>
Description
Expand All @@ -19804,8 +19806,8 @@ SELECT count(*) FROM sometable;
<returnvalue>bigint</returnvalue>
</para>
<para>
Returns the number of the current row within its partition, counting
from 1.
Renvoie le nombre de la ligne courante dans sa partition, en commençant
à 1.
</para></entry>
</row>

Expand All @@ -19818,9 +19820,9 @@ SELECT count(*) FROM sometable;
<returnvalue>bigint</returnvalue>
</para>
<para>
Returns the rank of the current row, with gaps; that is,
the <function>row_number</function> of the first row in its peer
group.
Renvoie le range de la ligne courante, avec des trous&nbsp;;
c'est-à-dire le <function>row_number</function> de la première ligne
dans son groupe.
</para></entry>
</row>

Expand All @@ -19833,8 +19835,8 @@ SELECT count(*) FROM sometable;
<returnvalue>bigint</returnvalue>
</para>
<para>
Returns the rank of the current row, without gaps; this function
effectively counts peer groups.
Renvoie le range de la ligne courante, sans trous&nbsp;; cette
fonction compte réellement les groupes.
</para></entry>
</row>

Expand All @@ -19847,9 +19849,9 @@ SELECT count(*) FROM sometable;
<returnvalue>double precision</returnvalue>
</para>
<para>
Returns the relative rank of the current row, that is
(<function>rank</function> - 1) / (total partition rows - 1).
The value thus ranges from 0 to 1 inclusive.
Renvoie le rang relatif de la ligne courante, c'est-à-dire
(<function>rank</function> - 1) / (total de lignes dans la partition - 1).
La valeur est donc comprise entre 0 et 1, les deux inclus.
</para></entry>
</row>

Expand All @@ -19862,9 +19864,10 @@ SELECT count(*) FROM sometable;
<returnvalue>double precision</returnvalue>
</para>
<para>
Returns the cumulative distribution, that is (number of partition rows
preceding or peers with current row) / (total partition rows).
The value thus ranges from 1/<parameter>N</parameter> to 1.
Renvoie la distribution cumulative, c'est-à-dire (nombre de lignes dans
la partition précédente ou nombre de groupes à partir de la ligne courante)
/ (total de lignes dans la partition).
La valeur est donc comprise entre 1/<parameter>N</parameter> et 1.
</para></entry>
</row>

Expand All @@ -19877,8 +19880,8 @@ SELECT count(*) FROM sometable;
<returnvalue>integer</returnvalue>
</para>
<para>
Returns an integer ranging from 1 to the argument value, dividing the
partition as equally as possible.
Renvoie un entier entre 1 et la valeur argument, divisant la partition
aussi également que possible.
</para></entry>
</row>

Expand All @@ -19893,17 +19896,14 @@ SELECT count(*) FROM sometable;
<returnvalue>anyelement</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated at
the row that is <parameter>offset</parameter>
rows before the current row within the partition; if there is no such
row, instead returns <parameter>default</parameter>
(which must be of the same type as
<parameter>value</parameter>).
Both <parameter>offset</parameter> and
<parameter>default</parameter> are evaluated
with respect to the current row. If omitted,
<parameter>offset</parameter> defaults to 1 and
<parameter>default</parameter> to <literal>NULL</literal>.
Renvoie <parameter>value</parameter> évaluée à la ligne qui se trouve
à <parameter>offset</parameter> lignes avant la ligne actuelle dans la
partition&nbsp;; si une telle ligne n'existe pas, renvoie
<parameter>default</parameter> à la place (qui doit être du même type
que <parameter>value</parameter>). <parameter>offset</parameter> et
<parameter>default</parameter> sont évalués suivant la ligne actuelle.
Par défaut, <parameter>offset</parameter> vaut 1 et
<parameter>default</parameter> vaut <literal>NULL</literal>.
</para></entry>
</row>

Expand All @@ -19918,17 +19918,14 @@ SELECT count(*) FROM sometable;
<returnvalue>anyelement</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated at
the row that is <parameter>offset</parameter>
rows after the current row within the partition; if there is no such
row, instead returns <parameter>default</parameter>
(which must be of the same type as
<parameter>value</parameter>).
Both <parameter>offset</parameter> and
<parameter>default</parameter> are evaluated
with respect to the current row. If omitted,
<parameter>offset</parameter> defaults to 1 and
<parameter>default</parameter> to <literal>NULL</literal>.
Renvoie <parameter>value</parameter> évaluée à la ligne qui se trouve
à <parameter>offset</parameter> lignes après la ligne actuelle dans la
partition&nbsp;; si une telle ligne n'existe pas, renvoie
<parameter>default</parameter> à la place (qui doit être du même type
que <parameter>value</parameter>). <parameter>offset</parameter> et
<parameter>default</parameter> sont évalués suivant la ligne actuelle.
Par défaut, <parameter>offset</parameter> vaut 1 et
<parameter>default</parameter> vaut <literal>NULL</literal>.
</para></entry>
</row>

Expand All @@ -19941,8 +19938,8 @@ SELECT count(*) FROM sometable;
<returnvalue>anyelement</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated
at the row that is the first row of the window frame.
Renvoie <parameter>value</parameter> évaluée à la première ligne de la
fenêtre.
</para></entry>
</row>

Expand All @@ -19955,8 +19952,8 @@ SELECT count(*) FROM sometable;
<returnvalue>anyelement</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated
at the row that is the last row of the window frame.
Renvoie <parameter>value</parameter> évaluée à la dernière ligne de la
fenêtre.
</para></entry>
</row>

Expand All @@ -19969,64 +19966,68 @@ SELECT count(*) FROM sometable;
<returnvalue>anyelement</returnvalue>
</para>
<para>
Returns <parameter>value</parameter> evaluated
at the row that is the <parameter>n</parameter>'th
row of the window frame (counting from 1);
returns <literal>NULL</literal> if there is no such row.
Renvoie <parameter>value</parameter> évaluée à la ligne qui se trouve
à la <parameter>n</parameter>-ième ligne de la fenêtre (en comptant à
partir de 1)&nbsp;; renvoie <literal>NULL</literal> si cette ligne
n'existe pas.
</para></entry>
</row>
</tbody>
</tgroup>
</table>

<para>
All of the functions listed in
<xref linkend="functions-window-table"/> depend on the sort ordering
specified by the <literal>ORDER BY</literal> clause of the associated window
definition. Rows that are not distinct when considering only the
<literal>ORDER BY</literal> columns are said to be <firstterm>peers</firstterm>.
The four ranking functions (including <function>cume_dist</function>) are
defined so that they give the same answer for all rows of a peer group.
Toutes les fonctions listées dans <xref linkend="functions-window-table"/>
dépendent de l'ordre de tri indiqué par la clause <literal>ORDER
BY</literal> sur la définition de la fenêtre associée. Les lignes qui ne
sont pas distinctes lors de la seule considération des colonnes
<literal>ORDER BY</literal> sont des <firstterm>peers</firstterm>. Les
quatre fonctions de rang (y compris <function>cume_dist</function>) sont
définies pour qu'elles donnent la même réponse pour toutes les lignes d'un
groupe peer.
</para>

<para>
Note that <function>first_value</function>, <function>last_value</function>, and
<function>nth_value</function> consider only the rows within the <quote>window
frame</quote>, which by default contains the rows from the start of the
partition through the last peer of the current row. This is
likely to give unhelpful results for <function>last_value</function> and
sometimes also <function>nth_value</function>. You can redefine the frame by
adding a suitable frame specification (<literal>RANGE</literal>,
<literal>ROWS</literal> or <literal>GROUPS</literal>) to
the <literal>OVER</literal> clause.
See <xref linkend="syntax-window-functions"/> for more information
about frame specifications.
Notez que les fonctions <function>first_value</function>,
<function>last_value</function> et <function>nth_value</function> ne
prennent en compte que les lignes à l'intérieur d'une
<quote>fenêtre</quote>, qui, par défaut, contient les lignes du début de la
partition jusqu'au dernier peer de la ligne actuelle. Ceci risque de donner
des résultats sans intérêt pour <function>last_value</function> et quelques
fois aussi pour <function>nth_value</function>. Vous pouvez redéfinir la
fenêtre en ajoutant une spécification convenable (<literal>RANGE</literal>,
<literal>ROWS</literal> ou <literal>GROUPS</literal>) à la clause
<literal>OVER</literal>. Voir <xref linkend="syntax-window-functions"/>
pour plus d'informations.
</para>

<para>
When an aggregate function is used as a window function, it aggregates
over the rows within the current row's window frame.
An aggregate used with <literal>ORDER BY</literal> and the default window frame
definition produces a <quote>running sum</quote> type of behavior, which may or
may not be what's wanted. To obtain
aggregation over the whole partition, omit <literal>ORDER BY</literal> or use
<literal>ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING</literal>.
Other frame specifications can be used to obtain other effects.
Quand une fonction d'agrégat est utilisée comme fonction de fenêtrage, elle
agrège les lignes dans la fenêtre de la ligne courante. Un agrégat utilisé
avec <literal>ORDER BY</literal> et la définition par défaut de la fenêtre
produit un type de comportement du style <quote>somme mouvante</quote>, qui
pourrait être ou pas ce qui est souhaité. Pour obtenir l'agrégat sur la
partition complète, n'utilisez pas <literal>ORDER BY</literal> ou utilisez
<literal>ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING</literal>. Les autres spécifications de fenêtre peuvent être
utilisées pour obtenir d'autres effets.
</para>

<note>
<para>
The SQL standard defines a <literal>RESPECT NULLS</literal> or
<literal>IGNORE NULLS</literal> option for <function>lead</function>, <function>lag</function>,
<function>first_value</function>, <function>last_value</function>, and
<function>nth_value</function>. This is not implemented in
<productname>PostgreSQL</productname>: the behavior is always the
same as the standard's default, namely <literal>RESPECT NULLS</literal>.
Likewise, the standard's <literal>FROM FIRST</literal> or <literal>FROM LAST</literal>
option for <function>nth_value</function> is not implemented: only the
default <literal>FROM FIRST</literal> behavior is supported. (You can achieve
the result of <literal>FROM LAST</literal> by reversing the <literal>ORDER BY</literal>
ordering.)
Le standard SQL définit une option <literal>RESPECT NULLS</literal> ou
<literal>IGNORE NULLS</literal> pour les fonctions
<function>lead</function>, <function>lag</function>,
<function>first_value</function>, <function>last_value</function> et
<function>nth_value</function>. Ceci n'est pas couvert dans
<productname>PostgreSQL</productname>&nbsp;: le comportement est toujours
identique au comportement par défaut du standard, autrement dit
<literal>RESPECT NULLS</literal>. De même, les options du standard
<literal>FROM FIRST</literal> et <literal>FROM LAST</literal> pour
<function>nth_value</function> ne sont pas supportées&nbsp;: seul le
comportement par défaut, <literal>FROM FIRST</literal>, l'est. (Vous
pouvez obtenir le résultat de <literal>FROM LAST</literal> en inversant le
tri <literal>ORDER BY</literal>.)
</para>
</note>

Expand Down

0 comments on commit a4a0479

Please sign in to comment.