mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
add alias partitionI, update tests, and docs
This commit is contained in:
parent
2f913f193c
commit
a90e10c438
@ -2984,7 +2984,7 @@ Result:
|
||||
└─────────┘
|
||||
```
|
||||
|
||||
## partitionId
|
||||
## partitionID
|
||||
|
||||
Computes the [partition ID](../../engines/table-engines/mergetree-family/custom-partitioning-key.md).
|
||||
|
||||
@ -2995,7 +2995,7 @@ This function is slow and should not be called for large amount of rows.
|
||||
**Syntax**
|
||||
|
||||
```sql
|
||||
partitionId(x[, y, ...]);
|
||||
partitionID(x[, y, ...]);
|
||||
```
|
||||
|
||||
**Arguments**
|
||||
@ -3025,18 +3025,18 @@ ORDER BY tuple();
|
||||
|
||||
INSERT INTO tab VALUES (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6);
|
||||
|
||||
SELECT i, j, partitionId(i), _partition_id FROM tab ORDER BY i, j;
|
||||
SELECT i, j, partitionID(i), _partition_id FROM tab ORDER BY i, j;
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
┌─i─┬─j─┬─partitionId(i)─┬─_partition_id─┐
|
||||
┌─i─┬─j─┬─partitionID(i)─┬─_partition_id─┐
|
||||
│ 1 │ 1 │ 1 │ 1 │
|
||||
│ 1 │ 2 │ 1 │ 1 │
|
||||
│ 1 │ 3 │ 1 │ 1 │
|
||||
└───┴───┴────────────────┴───────────────┘
|
||||
┌─i─┬─j─┬─partitionId(i)─┬─_partition_id─┐
|
||||
┌─i─┬─j─┬─partitionID(i)─┬─_partition_id─┐
|
||||
│ 2 │ 4 │ 2 │ 2 │
|
||||
│ 2 │ 5 │ 2 │ 2 │
|
||||
│ 2 │ 6 │ 2 │ 2 │
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
REGISTER_FUNCTION(PartitionId)
|
||||
{
|
||||
factory.registerFunction<FunctionPartitionId>();
|
||||
factory.registerAlias("partitionID", "partitionId", FunctionFactory::CaseInsensitive);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ def test_lost_last_part(start_cluster):
|
||||
"ALTER TABLE mt3 UPDATE id = 777 WHERE 1", settings={"mutations_sync": "0"}
|
||||
)
|
||||
|
||||
partition_id = node1.query("select partitionId('x')").strip()
|
||||
partition_id = node1.query("select partitionID('x')").strip()
|
||||
remove_part_from_disk(node1, "mt3", f"{partition_id}_0_0_0")
|
||||
|
||||
# other way to detect broken parts
|
||||
|
@ -8,17 +8,17 @@ insert into x values (1, 1), (1, 2), (1, 3), (2, 4), (2, 5), (2, 6);
|
||||
|
||||
set max_rows_to_read = 3;
|
||||
|
||||
select * from x where _partition_id = partitionId(1);
|
||||
select * from x where _partition_id = partitionID(1);
|
||||
|
||||
set max_rows_to_read = 5; -- one row for subquery + subquery
|
||||
|
||||
select * from x where _partition_id in (select partitionId(number + 1) from numbers(1));
|
||||
select * from x where _partition_id in (select partitionID(number + 1) from numbers(1));
|
||||
|
||||
-- trivial count optimization test
|
||||
set max_rows_to_read = 2; -- one row for subquery + subquery itself
|
||||
-- TODO: Relax the limits because we might build prepared set twice with _minmax_count_projection
|
||||
set max_rows_to_read = 3;
|
||||
select count() from x where _partition_id in (select partitionId(number + 1) from numbers(1));
|
||||
select count() from x where _partition_id in (select partitionID(number + 1) from numbers(1));
|
||||
|
||||
drop table x;
|
||||
|
||||
|
@ -2193,6 +2193,7 @@ parseTimeDelta
|
||||
parseable
|
||||
parsers
|
||||
partitionId
|
||||
partitionID
|
||||
pathFull
|
||||
pclmulqdq
|
||||
pcre
|
||||
|
Loading…
Reference in New Issue
Block a user