mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix StorageJoin truncate reset overwrite flag
This commit is contained in:
parent
4003dcd12e
commit
93b7b0bd3a
@ -43,7 +43,7 @@ StorageJoin::StorageJoin(
|
||||
ASTTableJoin::Strictness strictness_,
|
||||
const ColumnsDescription & columns_,
|
||||
const ConstraintsDescription & constraints_,
|
||||
bool overwrite,
|
||||
bool overwrite_,
|
||||
const Context & context_)
|
||||
: StorageSetOrJoinBase{relative_path_, table_id_, columns_, constraints_, context_}
|
||||
, key_names(key_names_)
|
||||
@ -51,6 +51,7 @@ StorageJoin::StorageJoin(
|
||||
, limits(limits_)
|
||||
, kind(kind_)
|
||||
, strictness(strictness_)
|
||||
, overwrite(overwrite_)
|
||||
{
|
||||
for (const auto & key : key_names)
|
||||
if (!getColumns().hasPhysical(key))
|
||||
@ -69,7 +70,7 @@ void StorageJoin::truncate(const ASTPtr &, const Context &, TableStructureWriteL
|
||||
Poco::File(path + "tmp/").createDirectories();
|
||||
|
||||
increment = 0;
|
||||
join = std::make_shared<Join>(table_join, getSampleBlock().sortColumns());
|
||||
join = std::make_shared<Join>(table_join, getSampleBlock().sortColumns(), overwrite);
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,7 @@ private:
|
||||
SizeLimits limits;
|
||||
ASTTableJoin::Kind kind; /// LEFT | INNER ...
|
||||
ASTTableJoin::Strictness strictness; /// ANY | ALL
|
||||
bool overwrite;
|
||||
|
||||
std::shared_ptr<AnalyzedJoin> table_join;
|
||||
HashJoinPtr join;
|
||||
|
@ -0,0 +1,3 @@
|
||||
500
|
||||
1000
|
||||
1000
|
27
dbms/tests/queries/0_stateless/01230_join_get_truncate.sql
Normal file
27
dbms/tests/queries/0_stateless/01230_join_get_truncate.sql
Normal file
@ -0,0 +1,27 @@
|
||||
DROP TABLE IF EXISTS join_test;
|
||||
|
||||
CREATE TABLE join_test (id UInt16, num UInt16) engine = Join(ANY, LEFT, id) settings join_any_take_last_row = 1;
|
||||
|
||||
INSERT INTO join_test (id, num) SELECT number, number FROM system.numbers LIMIT 1000;
|
||||
|
||||
SELECT joinGet('join_test', 'num', 500);
|
||||
|
||||
-- joinGet('join_test', 'num', 500) will be 500 and it is fine
|
||||
-- replace all the values
|
||||
|
||||
INSERT INTO join_test (id, num) SELECT number, number * 2 FROM system.numbers LIMIT 1000;
|
||||
|
||||
SELECT joinGet ('join_test', 'num', 500);
|
||||
|
||||
-- joinGet('join_test', 'num', 500) will be 1000 and it is fine
|
||||
|
||||
TRUNCATE TABLE join_test;
|
||||
|
||||
INSERT INTO join_test (id, num) SELECT number, number FROM system.numbers LIMIT 1000;
|
||||
|
||||
INSERT INTO join_test (id, num) SELECT number, number * 2 FROM system.numbers LIMIT 1000;
|
||||
|
||||
SELECT joinGet('join_test', 'num', 500);
|
||||
|
||||
-- joinGet('join_test', 'num', 500) will be 1000 and it is not fine
|
||||
DROP TABLE join_test;
|
Loading…
Reference in New Issue
Block a user