Skip to content

Commit 72504b2

Browse files
committed
tests
1 parent 576ef2b commit 72504b2

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

clickhouse/block.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ const BlockInfo& Block::Info() const {
7171
return info_;
7272
}
7373

74+
/// Set block info
75+
void Block::SetInfo(BlockInfo info) {
76+
info_ = std::move(info);
77+
}
78+
7479
/// Count of rows in the block.
7580
size_t Block::GetRowCount() const {
7681
return rows_;

clickhouse/block.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class Block {
7373

7474
const BlockInfo& Info() const;
7575

76+
/// Set block info
77+
void SetInfo(BlockInfo info);
78+
7679
/// Count of rows in the block.
7780
size_t GetRowCount() const;
7881

clickhouse/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ bool Client::Impl::ReadBlock(InputStream& input, Block* block) {
485485
return false;
486486
}
487487

488-
// TODO use data
488+
block->SetInfo(std::move(info));
489489
}
490490

491491
uint64_t num_columns = 0;

ut/client_ut.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,23 @@ TEST_P(ClientCase, RoundtripArrayTString) {
10101010
EXPECT_TRUE(CompareRecursive(*array, *result_typed));
10111011
}
10121012

1013+
TEST_P(ClientCase, WriteInfo) {
1014+
Block block;
1015+
createTableWithOneColumn<ColumnString>(block);
1016+
1017+
std::optional<Progress> received_progress;
1018+
Query query("INSERT INTO " + table_name + " (*) VALUES (\'Foo\'), (\'Bar\')" );
1019+
query.OnProgress([&](const Progress& progress) {
1020+
received_progress = progress;
1021+
});
1022+
client_->Execute(query);
1023+
1024+
EXPECT_TRUE(received_progress.has_value());
1025+
// server for some reason sent "rows" instead "written_rows"
1026+
EXPECT_GT(received_progress->rows + received_progress->written_rows , 0ul);
1027+
EXPECT_GT(received_progress->bytes + received_progress->written_bytes, 0ul);
1028+
}
1029+
10131030
const auto LocalHostEndpoint = ClientOptions()
10141031
.SetHost( getEnvOrDefault("CLICKHOUSE_HOST", "localhost"))
10151032
.SetPort( getEnvOrDefault<size_t>("CLICKHOUSE_PORT", "9000"))

0 commit comments

Comments
 (0)