Skip to content

Commit 16d17d0

Browse files
authored
Merge pull request ClickHouse#79844 from wxybear/fix_object_storage_cluster_wrong_count
fix: ObjectStorageCluster table function return wrong count() after applyTrivialCount optimized
2 parents 7548b1e + d930a8e commit 16d17d0

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/Storages/ObjectStorage/StorageObjectStorageCluster.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ std::string StorageObjectStorageCluster::getName() const
8585
return configuration->getEngineName();
8686
}
8787

88+
std::optional<UInt64> StorageObjectStorageCluster::totalRows(ContextPtr query_context) const
89+
{
90+
configuration->update(object_storage, query_context);
91+
return configuration->totalRows();
92+
}
93+
94+
std::optional<UInt64> StorageObjectStorageCluster::totalBytes(ContextPtr query_context) const
95+
{
96+
configuration->update(object_storage, query_context);
97+
return configuration->totalBytes();
98+
}
99+
88100
void StorageObjectStorageCluster::updateQueryToSendIfNeeded(
89101
ASTPtr & query,
90102
const DB::StorageSnapshotPtr & storage_snapshot,

src/Storages/ObjectStorage/StorageObjectStorageCluster.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class StorageObjectStorageCluster : public IStorageCluster
2929

3030
String getPathSample(StorageInMemoryMetadata metadata, ContextPtr context);
3131

32+
std::optional<UInt64> totalRows(ContextPtr query_context) const override;
33+
std::optional<UInt64> totalBytes(ContextPtr query_context) const override;
34+
3235
private:
3336
void updateQueryToSendIfNeeded(
3437
ASTPtr & query,

tests/integration/test_storage_iceberg/test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ def add_df(mode):
650650
)
651651
assert len(cluster_secondary_queries) == 1
652652

653+
# write 3 times
654+
assert int(instance.query(f"SELECT count() FROM {table_function_expr_cluster}")) == 100 * 3
653655

654656
@pytest.mark.parametrize("format_version", ["1", "2"])
655657
@pytest.mark.parametrize("storage_type", ["s3", "azure", "local"])

0 commit comments

Comments
 (0)