-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](load) only load source scanners update load counters #63781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
15 changes: 15 additions & 0 deletions
15
regression-test/data/load_p0/insert/test_scan_filtered_rows_not_pollute_load_counter.out
This file contains hidden or 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,15 @@ | ||
| -- This file is automatically generated. You should know what you did if you want to edit this | ||
| -- !insert_empty -- | ||
| 0 | ||
|
|
||
| -- !insert_empty_profile -- | ||
| 0 | ||
|
|
||
| -- !delete_noop -- | ||
| 3 | ||
|
|
||
| -- !update_noop -- | ||
| 1 1 | ||
| 2 2 | ||
| 3 3 | ||
|
|
||
94 changes: 94 additions & 0 deletions
94
...ession-test/suites/load_p0/insert/test_scan_filtered_rows_not_pollute_load_counter.groovy
This file contains hidden or 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,94 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| suite("test_scan_filtered_rows_not_pollute_load_counter", "p0") { | ||
| // Rows filtered by scan predicates of a query must not be counted as load | ||
| // "unselected" rows. Otherwise loadedRows reported to FE becomes negative | ||
| // (total 0 - unselected N) and the insert fails with errors like | ||
| // "Insert has too many filtered data 0/-10 insert_max_filter_ratio is 1.000000". | ||
|
liaoxin01 marked this conversation as resolved.
|
||
| def srcTable = "test_scan_filter_load_counter_src" | ||
| def dstTable = "test_scan_filter_load_counter_dst" | ||
| def uniqTable = "test_scan_filter_load_counter_uniq" | ||
|
|
||
| sql """ DROP TABLE IF EXISTS ${srcTable} """ | ||
| // Predicates on value columns of an AGGREGATE KEY table can neither be pushed | ||
| // down as column predicates nor as common expressions, so they are evaluated | ||
| // by the scanner conjuncts and counted into ScannerCounter.num_rows_unselected. | ||
| sql """ | ||
| CREATE TABLE ${srcTable} ( | ||
| k1 INT, | ||
| v1 INT REPLACE | ||
| ) AGGREGATE KEY(k1) | ||
| DISTRIBUTED BY HASH(k1) BUCKETS 1 | ||
| PROPERTIES ("replication_num" = "1"); | ||
| """ | ||
| sql """ | ||
| INSERT INTO ${srcTable} VALUES | ||
| (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10) | ||
| """ | ||
|
|
||
| sql """ DROP TABLE IF EXISTS ${dstTable} """ | ||
| sql """ | ||
| CREATE TABLE ${dstTable} ( | ||
| k1 INT | ||
| ) DUPLICATE KEY(k1) | ||
| DISTRIBUTED BY HASH(k1) BUCKETS 1 | ||
| PROPERTIES ("replication_num" = "1"); | ||
| """ | ||
|
|
||
| sql "set enable_insert_strict=false" | ||
| sql "set insert_max_filter_ratio=1" | ||
|
|
||
| // All 10 scanned rows are filtered inside the scanner; the insert must | ||
| // succeed as a no-op instead of failing the filter ratio check. | ||
| sql """ INSERT INTO ${dstTable} SELECT k1 FROM ${srcTable} WHERE v1 > 1000 """ | ||
| qt_insert_empty "select count(*) from ${dstTable}" | ||
|
|
||
| // Same with profile enabled, which was the original trigger of this issue. | ||
| sql "set enable_profile=true" | ||
| sql """ INSERT INTO ${dstTable} SELECT k1 FROM ${srcTable} WHERE v1 > 1000 """ | ||
| qt_insert_empty_profile "select count(*) from ${dstTable}" | ||
| sql "set enable_profile=false" | ||
|
|
||
| // DELETE ... WHERE EXISTS executes through the insert path (delete sign). | ||
| // A no-op delete whose source scan filters out all rows must succeed. | ||
| sql """ DROP TABLE IF EXISTS ${uniqTable} """ | ||
| sql """ | ||
| CREATE TABLE ${uniqTable} ( | ||
| k1 INT, | ||
| v1 INT | ||
| ) UNIQUE KEY(k1) | ||
| DISTRIBUTED BY HASH(k1) BUCKETS 1 | ||
| PROPERTIES ("replication_num" = "1"); | ||
| """ | ||
| sql """ INSERT INTO ${uniqTable} VALUES (1,1),(2,2),(3,3) """ | ||
| sql """ | ||
| DELETE FROM ${uniqTable} t WHERE EXISTS ( | ||
| SELECT 1 FROM ${srcTable} s WHERE s.k1 = t.k1 AND s.v1 > 1000 | ||
| ) | ||
| """ | ||
| qt_delete_noop "select count(*) from ${uniqTable}" | ||
|
|
||
| // UPDATE also executes through the insert path; a no-op update whose | ||
| // subquery scan filters out all rows must succeed. | ||
| sql """ | ||
| UPDATE ${uniqTable} SET v1 = 100 WHERE k1 IN ( | ||
| SELECT k1 FROM ${srcTable} WHERE v1 > 1000 | ||
| ) | ||
| """ | ||
| qt_update_noop "select * from ${uniqTable} order by k1" | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.