Clarify how ORDER BY works with UNION ALL (#10561)

Hopefully a bit clearer.
This commit is contained in:
Gian Merlino 2020-11-05 20:12:03 -08:00 committed by GitHub
parent 6ccddedb7a
commit 3436297354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -167,9 +167,9 @@ together and appear one after the other.
#### Table-level
UNION ALL can be used to query multiple tables at the same time. In this case, it must appear in the FROM clause,
and the subqueries that are inputs to the UNION ALL operator must be simple table SELECTs (no expressions, column
aliasing, etc). The query will run natively using a [union datasource](datasource.md#union).
UNION ALL can be used to query multiple tables at the same time. In this case, it must appear in a subquery in the
FROM clause, and the lower-level subqueries that are inputs to the UNION ALL operator must be simple table SELECTs
(no expressions, column aliasing, etc). The query will run natively using a [union datasource](datasource.md#union).
The same columns must be selected from each table in the same order, and those columns must either have the same types,
or types that can be implicitly cast to each other (such as different numeric types). For this reason, it is generally
@ -190,7 +190,7 @@ GROUP BY col1
When UNION ALL occurs at the table level, the rows from the unioned tables are not guaranteed to be processed in
any particular order. They may be processed in an interleaved fashion. If you need a particular result ordering,
use [ORDER BY](#order-by).
use [ORDER BY](#order-by) on the outer query.
### EXPLAIN PLAN