mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Merge pull request #50923 from ClickHouse/read-in-order-proj-bug
Do not apply projection if read-in-order was enabled.
This commit is contained in:
commit
5163927b7d
@ -38,6 +38,9 @@ bool canUseProjectionForReadingStep(ReadFromMergeTree * reading)
|
||||
if (reading->isParallelReadingEnabled())
|
||||
return false;
|
||||
|
||||
if (reading->readsInOrder())
|
||||
return false;
|
||||
|
||||
// Currently projection don't support deduplication when moving parts between shards.
|
||||
if (reading->getContext()->getSettingsRef().allow_experimental_query_deduplication)
|
||||
return false;
|
||||
|
@ -1427,6 +1427,11 @@ bool ReadFromMergeTree::requestReadingInOrder(size_t prefix_size, int direction,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadFromMergeTree::readsInOrder() const
|
||||
{
|
||||
return reader_settings.read_in_order;
|
||||
}
|
||||
|
||||
void ReadFromMergeTree::updatePrewhereInfo(const PrewhereInfoPtr & prewhere_info_value)
|
||||
{
|
||||
query_info.prewhere_info = prewhere_info_value;
|
||||
|
@ -161,6 +161,7 @@ public:
|
||||
|
||||
/// Returns `false` if requested reading cannot be performed.
|
||||
bool requestReadingInOrder(size_t prefix_size, int direction, size_t limit);
|
||||
bool readsInOrder() const;
|
||||
|
||||
void updatePrewhereInfo(const PrewhereInfoPtr & prewhere_info_value);
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
00000000-0000-0000-0000-000000000000 1643760000 0
|
||||
00000000-0000-0000-0000-000000000000 1643760000 0
|
||||
00000000-0000-0000-0000-000000000000 1643760000 0
|
||||
00000000-0000-0000-0000-000000000000 1643760000 0
|
@ -0,0 +1,44 @@
|
||||
create table events (
|
||||
`organisation_id` UUID,
|
||||
`session_id` UUID,
|
||||
`id` UUID DEFAULT generateUUIDv4(),
|
||||
`timestamp` UInt64,
|
||||
`payload` String,
|
||||
`customer_id` UUID,
|
||||
`call_id` String,
|
||||
PROJECTION events_by_session_and_org
|
||||
(
|
||||
SELECT *
|
||||
ORDER BY
|
||||
organisation_id,
|
||||
session_id,
|
||||
timestamp
|
||||
),
|
||||
PROJECTION events_by_session
|
||||
(
|
||||
SELECT *
|
||||
ORDER BY
|
||||
session_id,
|
||||
timestamp
|
||||
),
|
||||
PROJECTION events_by_session_and_customer
|
||||
(
|
||||
SELECT *
|
||||
ORDER BY
|
||||
customer_id,
|
||||
session_id,
|
||||
timestamp
|
||||
),
|
||||
PROJECTION events_by_call_id
|
||||
(
|
||||
SELECT *
|
||||
ORDER BY
|
||||
call_id,
|
||||
timestamp
|
||||
)) engine = MergeTree order by (organisation_id, session_id, timestamp) settings index_granularity = 3;
|
||||
|
||||
insert into events values (reinterpretAsUUID(0), reinterpretAsUUID(1), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(0), reinterpretAsUUID(1), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(1), reinterpretAsUUID(0), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(1), reinterpretAsUUID(0), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(3), reinterpretAsUUID(2), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(3), reinterpretAsUUID(2), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0));
|
||||
insert into events values (reinterpretAsUUID(0), reinterpretAsUUID(1), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(0), reinterpretAsUUID(1), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(1), reinterpretAsUUID(0), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(1), reinterpretAsUUID(0), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(3), reinterpretAsUUID(2), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0)), (reinterpretAsUUID(3), reinterpretAsUUID(2), reinterpretAsUUID(0), toDateTime('2022-02-02', 'UTC'), toString(0), reinterpretAsUUID(0), toString(0));
|
||||
|
||||
set read_in_order_two_level_merge_threshold=1;
|
||||
SELECT id, timestamp, payload FROM events WHERE (organisation_id = reinterpretAsUUID(1)) AND (session_id = reinterpretAsUUID(0)) ORDER BY timestamp, payload, id ASC;
|
Loading…
Reference in New Issue
Block a user