Document the enable_positional_arguments setting

This commit is contained in:
Tatiana Kirillova 2021-10-04 20:49:21 +03:00
parent 613b814e24
commit 1c62a53afe
2 changed files with 37 additions and 1 deletions

View File

@ -3749,3 +3749,39 @@ Exception: Total regexp lengths too large.
**See Also**
- [max_hyperscan_regexp_length](#max-hyperscan-regexp-length)
## enable_positional_arguments {#enable-positional-arguments}
Enables or disables supporting positional arguments for [GROUP BY](../../sql-reference/statements/select/group-by.md), [LIMIT BY](../../sql-reference/statements/select/limit-by.md), [ORDER BY](../../sql-reference/statements/select/order-by.md) statement. When you want to use column numbers instead of titles in these clauses, set `enable_positional_arguments = 1`.
Possible values:
- 0 — Disabled.
- 1 — Enabled.
Default value: `0`.
**Example**
Query:
```sql
CREATE TABLE positional_arguments(one Int, two Int, tree Int) ENGINE=Memory();
INSERT INTO positional_arguments VALUES (10, 20, 30), (20, 30, 10), (30, 10, 20);
SET enable_positional_arguments = 1;
SELECT * FROM positional_arguments ORDER BY 2,3;
```
Result:
```text
┌─one─┬─two─┬─tree─┐
│ 30 │ 10 │ 20 │
│ 10 │ 20 │ 30 │
│ 20 │ 30 │ 10 │
└─────┴─────┴──────┘
```

View File

@ -144,7 +144,7 @@ Extreme values are calculated for rows before `LIMIT`, but after `LIMIT BY`. How
You can use synonyms (`AS` aliases) in any part of a query.
The `GROUP BY` and `ORDER BY` clauses do not support positional arguments. This contradicts MySQL, but conforms to standard SQL. For example, `GROUP BY 1, 2` will be interpreted as grouping by constants (i.e. aggregation of all rows into one).
The `GROUP BY`, `ORDER BY` and `LIMIT BY` clauses support positional arguments. For example, ORDER BY 1,2 will be sorting rows on the table on the first and then the second column.
## Implementation Details {#implementation-details}