Skip to content

Commit ad82f5b

Browse files
committed
fix: system.tables not suppport total_bytes_uncompressed until v24.8+ when get materialized view
1 parent 8bba8fa commit ad82f5b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

service/clickhouse/clickhouse.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,17 @@ func GetVmStatus(conf *model.CKManClickHouseConfig) (map[string]*model.CkVmStatu
580580
if err != nil {
581581
return nil, err
582582
}
583+
uncompressed := "sum(0)"
584+
if common.CompareClickHouseVersion(conf.Version, "24.8.x") >= 0 {
585+
uncompressed = "sum(total_bytes_uncompressed)"
586+
}
583587
query := fmt.Sprintf(`SELECT
584588
database,
585589
name,
586590
sum(parts),
587591
sum(total_rows),
588592
sum(total_bytes),
589-
sum(total_bytes_uncompressed),
593+
%s,
590594
(extractAllGroups(as_select, 'FROM ([\\w\\d_]+\\.[\\w+\\d_]+)')[1])[1] AS source_table,
591595
as_select
592596
FROM cluster('%s', system.tables)
@@ -595,7 +599,7 @@ GROUP BY
595599
database,
596600
name,
597601
source_table,
598-
as_select`, conf.Cluster)
602+
as_select`, uncompressed, conf.Cluster)
599603

600604
data, err := service.QueryInfo(query)
601605
if err != nil {

0 commit comments

Comments
 (0)