Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53511 from Enmk/fix-ReplacingMergeTree-do_not_mer…
…ge_across_partitions_select_final Fixed SELECTing from ReplacingMergeTree with do_not_merge_across_partitions_select_final
- Loading branch information
Showing
3 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...eries/0_stateless/02814_ReplacingMergeTree_fix_select_final_on_single_partition.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- Based on https://github.com/ClickHouse/ClickHouse/issues/49685 | ||
--- Verify that ReplacingMergeTree properly handles _is_deleted: | ||
--- SELECT FINAL should take `_is_deleted` into consideration when there is only one partition. | ||
-- { echoOn } | ||
|
||
DROP TABLE IF EXISTS t; | ||
CREATE TABLE t | ||
( | ||
`account_id` UInt64, | ||
`_is_deleted` UInt8, | ||
`_version` UInt64 | ||
) | ||
ENGINE = ReplacingMergeTree(_version, _is_deleted) | ||
ORDER BY (account_id); | ||
INSERT INTO t SELECT number, 0, 1 FROM numbers(1e3); | ||
-- Mark the first 100 rows as deleted. | ||
INSERT INTO t SELECT number, 1, 1 FROM numbers(1e2); | ||
-- Put everything in one partition | ||
OPTIMIZE TABLE t FINAL; | ||
SELECT count() FROM t; | ||
1000 | ||
SELECT count() FROM t FINAL; | ||
900 | ||
-- Both should produce the same number of rows. | ||
-- Previously, `do_not_merge_across_partitions_select_final = 1` showed more rows, | ||
-- as if no rows were deleted. | ||
SELECT count() FROM t FINAL SETTINGS do_not_merge_across_partitions_select_final = 1; | ||
900 | ||
SELECT count() FROM t FINAL SETTINGS do_not_merge_across_partitions_select_final = 0; | ||
900 | ||
DROP TABLE t; |
32 changes: 32 additions & 0 deletions
32
tests/queries/0_stateless/02814_ReplacingMergeTree_fix_select_final_on_single_partition.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- Based on https://github.com/ClickHouse/ClickHouse/issues/49685 | ||
--- Verify that ReplacingMergeTree properly handles _is_deleted: | ||
--- SELECT FINAL should take `_is_deleted` into consideration when there is only one partition. | ||
-- { echoOn } | ||
|
||
DROP TABLE IF EXISTS t; | ||
CREATE TABLE t | ||
( | ||
`account_id` UInt64, | ||
`_is_deleted` UInt8, | ||
`_version` UInt64 | ||
) | ||
ENGINE = ReplacingMergeTree(_version, _is_deleted) | ||
ORDER BY (account_id); | ||
|
||
INSERT INTO t SELECT number, 0, 1 FROM numbers(1e3); | ||
-- Mark the first 100 rows as deleted. | ||
INSERT INTO t SELECT number, 1, 1 FROM numbers(1e2); | ||
|
||
-- Put everything in one partition | ||
OPTIMIZE TABLE t FINAL; | ||
|
||
SELECT count() FROM t; | ||
SELECT count() FROM t FINAL; | ||
|
||
-- Both should produce the same number of rows. | ||
-- Previously, `do_not_merge_across_partitions_select_final = 1` showed more rows, | ||
-- as if no rows were deleted. | ||
SELECT count() FROM t FINAL SETTINGS do_not_merge_across_partitions_select_final = 1; | ||
SELECT count() FROM t FINAL SETTINGS do_not_merge_across_partitions_select_final = 0; | ||
|
||
DROP TABLE t; |