Merge pull request #68897 from ClickHouse/revert-59173-fix_prewhere_without_columns

Revert "Fix prewhere without columns and without adaptive index granularity (almost w/o anything)"
This commit is contained in:
alesapin 2024-08-27 10:15:35 +00:00 committed by GitHub
commit df44c2a4ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 3 additions and 91 deletions

View File

@ -1334,17 +1334,6 @@ void IMergeTreeDataPart::loadRowsCount()
auto buf = metadata_manager->read("count.txt"); auto buf = metadata_manager->read("count.txt");
readIntText(rows_count, *buf); readIntText(rows_count, *buf);
assertEOF(*buf); assertEOF(*buf);
if (!index_granularity.empty() && rows_count < index_granularity.getTotalRows() && index_granularity_info.fixed_index_granularity)
{
/// Adjust last granule size to match the number of rows in the part in case of fixed index_granularity.
index_granularity.popMark();
index_granularity.appendMark(rows_count % index_granularity_info.fixed_index_granularity);
if (rows_count != index_granularity.getTotalRows())
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Index granularity total rows in part {} does not match rows_count: {}, instead of {}",
name, index_granularity.getTotalRows(), rows_count);
}
}; };
if (index_granularity.empty()) if (index_granularity.empty())

View File

@ -577,10 +577,7 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const NameAndTypePai
if (index_granularity_rows != index_granularity.getMarkRows(mark_num)) if (index_granularity_rows != index_granularity.getMarkRows(mark_num))
{ {
/// With fixed granularity we can have last mark with less rows than granularity throw Exception(
const bool is_last_mark = (mark_num + 1 == index_granularity.getMarksCount());
if (!index_granularity_info.fixed_index_granularity || !is_last_mark)
throw Exception(
ErrorCodes::LOGICAL_ERROR, ErrorCodes::LOGICAL_ERROR,
"Incorrect mark rows for part {} for mark #{}" "Incorrect mark rows for part {} for mark #{}"
" (compressed offset {}, decompressed offset {}), in-memory {}, on disk {}, total marks {}", " (compressed offset {}, decompressed offset {}), in-memory {}, on disk {}, total marks {}",
@ -844,14 +841,7 @@ void MergeTreeDataPartWriterWide::adjustLastMarkIfNeedAndFlushToDisk(size_t new_
/// Without offset /// Without offset
rows_written_in_last_mark = 0; rows_written_in_last_mark = 0;
} }
if (compute_granularity)
{
index_granularity.popMark();
index_granularity.appendMark(new_rows_in_last_mark);
}
} }
} }
} }

View File

@ -1,51 +0,0 @@
CREATE TABLE t_02967
(
`key` Date,
`value` UInt16
)
ENGINE = MergeTree
ORDER BY key
SETTINGS
index_granularity_bytes = 0 --8192 --, min_index_granularity_bytes = 2
, index_granularity = 100
, min_rows_for_wide_part = 0, min_bytes_for_wide_part = 0
--
-- , min_bytes_for_wide_part = 2
AS SELECT
number,
repeat(toString(number), 5)
FROM numbers(105.);
-- Check with newly inserted data part. It's in-memory structured are filled at insert time.
SELECT
count(ignore(*))
FROM t_02967
PREWHERE CAST(ignore() + 1 as UInt8)
GROUP BY
ignore(65535, *),
ignore(255, 256, *)
SETTINGS
--send_logs_level='test',
max_threads=1;
-- Reload part form disk to check that in-meory structures where properly serilaized-deserialized
DETACH TABLE t_02967;
ATTACH TABLE t_02967;
SELECT
count(ignore(*))
FROM t_02967
PREWHERE CAST(ignore() + 1 as UInt8)
GROUP BY
ignore(65535, *),
ignore(255, 256, *)
SETTINGS
--send_logs_level='test',
max_threads=1;
DROP TABLE t_02967;

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS data_02051__fuzz_24;
CREATE TABLE data_02051__fuzz_24 (`key` Int16, `value` String) ENGINE = MergeTree ORDER BY key SETTINGS index_granularity_bytes = 0, min_rows_for_wide_part = 0, min_bytes_for_wide_part=0 AS SELECT number, repeat(toString(number), 5) FROM numbers(1000000.);
SELECT count(ignore(*)) FROM data_02051__fuzz_24 PREWHERE materialize(1) GROUP BY ignore(*);
detach table data_02051__fuzz_24;
attach table data_02051__fuzz_24;
SELECT count(ignore(*)) FROM data_02051__fuzz_24 PREWHERE materialize(1) GROUP BY ignore(*);
DROP TABLE data_02051__fuzz_24;

View File

@ -1,5 +1,5 @@
test hits 1 57344 7 test hits 1 57344 7
test hits 1 8832938 1079 test hits 1 8839168 1079
test hits 1 829354 102 test hits 1 835584 102
test hits 1 8003584 977 test hits 1 8003584 977
test hits 2 581632 71 test hits 2 581632 71