Skip to content

Commit

Permalink
Export of internal ZetaSQL changes.
Browse files Browse the repository at this point in the history
--
Change by Matthew Brown <[email protected]>:
Additional RewriteVisitor tests for error paths.
--
Change by Matthew Brown <[email protected]>:
ZetaSQL: Fix small issues blocking release
--
Change by ZetaSQL Team <[email protected]>:
Internal change

GitOrigin-RevId: e1cd537590fec7a87d0e8b4967dcee93a711105a
Change-Id: I5ebfc43120f6e0ec3f230893b5e3ac0608b68384
  • Loading branch information
ZetaSQL Team authored and matthewcbrown committed Apr 26, 2023
1 parent 06e004b commit 206e78c
Show file tree
Hide file tree
Showing 29 changed files with 921 additions and 148 deletions.
75 changes: 45 additions & 30 deletions docs/aggregate_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ rows. Returns `NULL` when `expression` is `NULL` for all rows in the group.
`ANY_VALUE` behaves as if `RESPECT NULLS` is specified;
rows for which `expression` is `NULL` are considered and may be selected.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -159,8 +160,9 @@ window_specification:

Returns an ARRAY of `expression` values.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -321,8 +323,9 @@ This function ignores `NULL` input arrays, but respects the `NULL` elements in
non-`NULL` input arrays. Returns `NULL` if there are zero input rows or
`expression` evaluates to `NULL` for all rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -422,8 +425,9 @@ window_specification:

Returns the average of non-`NULL` values in an aggregated group.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -537,8 +541,9 @@ BIT_AND(

Performs a bitwise AND operation on `expression` and returns the result.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -583,8 +588,9 @@ BIT_OR(

Performs a bitwise OR operation on `expression` and returns the result.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -629,8 +635,9 @@ BIT_XOR(

Performs a bitwise XOR operation on `expression` and returns the result.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -717,8 +724,9 @@ window_specification:
2. Returns the number of rows with `expression` evaluated to any value other
than `NULL`.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -904,8 +912,9 @@ COUNT(DISTINCT IF(condition, expression, NULL))
Note that this uses `COUNT`, not `COUNTIF`; the `IF` part has been moved inside.
To learn more, see the examples for [`COUNT`](#count).

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -989,8 +998,9 @@ window_specification:
Returns the logical AND of all non-`NULL` expressions. Returns `NULL` if there
are zero input rows or `expression` evaluates to `NULL` for all rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -1055,8 +1065,9 @@ window_specification:
Returns the logical OR of all non-`NULL` expressions. Returns `NULL` if there
are zero input rows or `expression` evaluates to `NULL` for all rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -1126,8 +1137,9 @@ Caveats:
the group, returns `NULL`.
+ If the argument is `NaN` for any row in the group, returns `NaN`.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -1217,8 +1229,9 @@ Caveats:
the group, returns `NULL`.
+ If the argument is `NaN` for any row in the group, returns `NaN`.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -1310,8 +1323,9 @@ evaluates to `NULL` for all rows.
If a `delimiter` is specified, concatenated values are separated by that
delimiter; otherwise, a comma is used as a delimiter.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -1446,8 +1460,9 @@ window_specification:

Returns the sum of non-`NULL` values in an aggregated group.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down
17 changes: 10 additions & 7 deletions docs/approximate_aggregate_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ already approximate.
The approximate aggregate functions in this section work directly on the
input data, rather than an intermediate estimation of the data. These functions
_do not allow_ users to specify the precision for the estimation with
sketches. If you would like specify precision with sketches, see:
sketches. If you would like to specify precision with sketches, see:

+ [HyperLogLog++ functions][hll-functions] to estimate cardinality.
+ [KLL functions][kll-functions] to estimate quantile values.
Expand Down Expand Up @@ -86,8 +86,9 @@ minimum and the last element is the approximate maximum.
Returns `NULL` if there are zero input rows or `expression` evaluates to
`NULL` for all rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -185,8 +186,9 @@ number of times the value was returned.

Returns `NULL` if there are zero input rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down Expand Up @@ -256,8 +258,9 @@ associated with the `value` field.

Returns `NULL` if there are zero input rows.

To learn more about the optional arguments in this function and how to use them,
see [Aggregate function calls][aggregate-function-calls].
To learn more about the optional aggregate clauses that you can pass
into this function, see
[Aggregate function calls][aggregate-function-calls].

<!-- mdlint off(WHITESPACE_LINE_LENGTH) -->

Expand Down
14 changes: 8 additions & 6 deletions docs/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,9 @@ calculations.
<td style="vertical-align:middle">
Precision: 38<br>
Scale: 9<br>
Minimum value greater than 0 that can be handled: 1e9<br>
Min: -9.9999999999999999999999999999999999999E+28<br>
Max: 9.9999999999999999999999999999999999999E+28
Max: 9.9999999999999999999999999999999999999E+28<br>
</td>
</tr>

Expand All @@ -1132,8 +1133,9 @@ calculations.
<td style="vertical-align:middle">
Precision: 76.76 (the 77th digit is partial)<br>
Scale: 38<br>
Minimum value greater than 0 that can be handled: 1e38<br>
Min: <small>-5.7896044618658097711785492504343953926634992332820282019728792003956564819968E+38</small><br>
Max: <small>5.7896044618658097711785492504343953926634992332820282019728792003956564819967E+38</small>
Max: <small>5.7896044618658097711785492504343953926634992332820282019728792003956564819967E+38</small><br>
</td>
</tr>

Expand All @@ -1144,10 +1146,10 @@ calculations.

`BIGDECIMAL` is an alias for `BIGNUMERIC`.

To learn more about the literal representation of a `DECIMAL` type,
To learn more about the literal representation of a `NUMERIC` type,
see [`NUMERIC` literals][numeric-literals].

To learn more about the literal representation of a `BIGDECIMAL` type,
To learn more about the literal representation of a `BIGNUMERIC` type,
see [`BIGNUMERIC` literals][bignumeric-literals].

### Floating point types
Expand Down Expand Up @@ -1209,9 +1211,9 @@ Floating point values are approximations.
In other situations, the approximation can be visible.
+ Summation of floating point values might produce surprising results because
of [limited precision][floating-point-accuracy]. For example,
`(1e30 + 1e-20) - 1e30 = 0`, while `(1e30 - 1e30) + 1e-20 = 1e-20`. This is
`(1e30 + 1) - 1e30 = 0`, while `(1e30 - 1e30) + 1 = 1.0`. This is
because the floating point value does not have enough precision to
represent `(1e30 + 1e-20)`, and the result is rounded to `1e30`.
represent `(1e30 + 1)`, and the result is rounded to `1e30`.
This example also shows that the result of the `SUM` aggregate function of
floating points values depends on the order in which the values are
accumulated. In general, this order is not deterministic and therefore the
Expand Down
Loading

0 comments on commit 206e78c

Please sign in to comment.