|
180 | 180 | "named_struct",
|
181 | 181 | "nanvl",
|
182 | 182 | "now",
|
| 183 | + "nth_value", |
183 | 184 | "nullif",
|
184 | 185 | "octet_length",
|
185 | 186 | "order_by",
|
@@ -1739,9 +1740,18 @@ def covar(value_y: Expr, value_x: Expr, filter: Optional[Expr] = None) -> Expr:
|
1739 | 1740 | return covar_samp(value_y, value_x, filter)
|
1740 | 1741 |
|
1741 | 1742 |
|
1742 |
| -def max(arg: Expr, distinct: bool = False) -> Expr: |
1743 |
| - """Returns the maximum value of the argument.""" |
1744 |
| - return Expr(f.max(arg.expr, distinct=distinct)) |
| 1743 | +def max(expression: Expr, filter: Optional[Expr] = None) -> Expr: |
| 1744 | + """Aggregate function that returns the maximum value of the argument. |
| 1745 | +
|
| 1746 | + If using the builder functions described in ref:`_aggregation` this function ignores |
| 1747 | + the options ``order_by``, ``null_treatment``, and ``distinct``. |
| 1748 | +
|
| 1749 | + Args: |
| 1750 | + expression: The value to find the maximum of |
| 1751 | + filter: If provided, only compute against rows for which the filter is true |
| 1752 | + """ |
| 1753 | + filter_raw = filter.expr if filter is not None else None |
| 1754 | + return Expr(f.max(expression.expr, filter=filter_raw)) |
1745 | 1755 |
|
1746 | 1756 |
|
1747 | 1757 | def mean(expression: Expr, filter: Optional[Expr] = None) -> Expr:
|
@@ -1772,9 +1782,18 @@ def median(
|
1772 | 1782 | return Expr(f.median(expression.expr, distinct=distinct, filter=filter_raw))
|
1773 | 1783 |
|
1774 | 1784 |
|
1775 |
| -def min(arg: Expr, distinct: bool = False) -> Expr: |
1776 |
| - """Returns the minimum value of the argument.""" |
1777 |
| - return Expr(f.min(arg.expr, distinct=distinct)) |
| 1785 | +def min(expression: Expr, filter: Optional[Expr] = None) -> Expr: |
| 1786 | + """Returns the minimum value of the argument. |
| 1787 | +
|
| 1788 | + If using the builder functions described in ref:`_aggregation` this function ignores |
| 1789 | + the options ``order_by``, ``null_treatment``, and ``distinct``. |
| 1790 | +
|
| 1791 | + Args: |
| 1792 | + expression: The value to find the minimum of |
| 1793 | + filter: If provided, only compute against rows for which the filter is true |
| 1794 | + """ |
| 1795 | + filter_raw = filter.expr if filter is not None else None |
| 1796 | + return Expr(f.min(expression.expr, filter=filter_raw)) |
1778 | 1797 |
|
1779 | 1798 |
|
1780 | 1799 | def sum(arg: Expr) -> Expr:
|
@@ -1933,6 +1952,41 @@ def last_value(
|
1933 | 1952 | )
|
1934 | 1953 |
|
1935 | 1954 |
|
| 1955 | +def nth_value( |
| 1956 | + expression: Expr, |
| 1957 | + n: int, |
| 1958 | + filter: Optional[Expr] = None, |
| 1959 | + order_by: Optional[list[Expr]] = None, |
| 1960 | + null_treatment: NullTreatment = NullTreatment.RESPECT_NULLS, |
| 1961 | +) -> Expr: |
| 1962 | + """Returns the n-th value in a group of values. |
| 1963 | +
|
| 1964 | + This aggregate function will return the n-th value in the partition. |
| 1965 | +
|
| 1966 | + If using the builder functions described in ref:`_aggregation` this function ignores |
| 1967 | + the option ``distinct``. |
| 1968 | +
|
| 1969 | + Args: |
| 1970 | + expression: Argument to perform bitwise calculation on |
| 1971 | + n: Index of value to return. Starts at 1. |
| 1972 | + filter: If provided, only compute against rows for which the filter is true |
| 1973 | + order_by: Set the ordering of the expression to evaluate |
| 1974 | + null_treatment: Assign whether to respect or ignull null values. |
| 1975 | + """ |
| 1976 | + order_by_raw = expr_list_to_raw_expr_list(order_by) |
| 1977 | + filter_raw = filter.expr if filter is not None else None |
| 1978 | + |
| 1979 | + return Expr( |
| 1980 | + f.nth_value( |
| 1981 | + expression.expr, |
| 1982 | + n, |
| 1983 | + filter=filter_raw, |
| 1984 | + order_by=order_by_raw, |
| 1985 | + null_treatment=null_treatment.value, |
| 1986 | + ) |
| 1987 | + ) |
| 1988 | + |
| 1989 | + |
1936 | 1990 | def bit_and(expression: Expr, filter: Optional[Expr] = None) -> Expr:
|
1937 | 1991 | """Computes the bitwise AND of the argument.
|
1938 | 1992 |
|
|
0 commit comments