Repository navigation
Generalized partitioning code 2 - #1235
Conversation
ztlpn
commented
Sep 12, 2017
- Version MergeTree data format
- Allow arbitrary partition literals in ALTER PARTITION queries
- Add experimental syntax for custom partitioning (for testing purposes)
…it [#CLICKHOUSE-3000]
…[#CLICKHOUSE-3000]
… partition_id [#CLICKHOUSE-3000]
| { | ||
| if (compareAt(i, min_idx, *this, /* nan_direction_hint = */ 1) < 0) | ||
| min_idx = i; | ||
| if (compareAt(i, max_idx, *this, /* nan_direction_hint = */ -1) > 0) |
| result += toString(DateLUT::instance().toNumYYYYMMDD(DayNum_t(value[i].get<UInt64>()))); | ||
| else | ||
| result += applyVisitor(to_string_visitor, value[i]); | ||
| } |
There was a problem hiding this comment.
I assume that you had the same thoughts while writing this code:
"we cannot do the same for DateTime because it will depend on timezones".
Better to write it in comment.
There was a problem hiding this comment.
Actually no, I was just lazy :) Good point.
| : partition_lit->value.safeGet<String>(); | ||
| } | ||
| else | ||
| prefix = getPartitionIDFromQuery(partition_ast, context); |
There was a problem hiding this comment.
Possibly unintended behavior if you have numeric partition key and partitions
1
11
111
(that have common prefix)
There was a problem hiding this comment.
I am unsure if this is needed (in case of custom partitioning we can forbid prefixes and allow only exact matches), though when partitioning is by date it will be handy. Proper way is of course to implement some form of ALTER PARTITION WHERE.
There was a problem hiding this comment.
On the second thought I am inclined to forbid it in case of custom partitioning. Because otherwise a user will be unable to freeze only partition '1' without also freezing partition '11'.
|
|
||
| STRONG_TYPEDEF(UInt32, MergeTreeDataFormatVersion); | ||
|
|
||
| const MergeTreeDataFormatVersion MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING {1}; |
There was a problem hiding this comment.
It can fail at link time if we ever take an address of this constant (example: debug build and passing it to std::max).
There was a problem hiding this comment.
Global constants should be OK (they have internal linkage by default). The problem may be with static const class members, but it is not the case here.