diff --git a/ChangeLog.md b/ChangeLog.md index b0c5b541..26313e7a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ # v2.4.24 BUG FIXES -- fix `check_parts_columns` corner cases for AggregateFunction versioning, fix [819](https://github.com/Altinity/clickhouse-backup/issues/819) +- fix `check_parts_columns` corner cases for `AggregateFunction` and `SimpleAggregateFunction` versioning, fix [819](https://github.com/Altinity/clickhouse-backup/issues/819) # v2.4.23 IMPROVEMENTS diff --git a/pkg/clickhouse/clickhouse.go b/pkg/clickhouse/clickhouse.go index 4cb2a72a..fe6e717a 100644 --- a/pkg/clickhouse/clickhouse.go +++ b/pkg/clickhouse/clickhouse.go @@ -1195,8 +1195,9 @@ func (ch *ClickHouse) CheckTypesConsistency(table *Table, partColumnsDataTypes [ isAggregationPresent := false uniqTypes := common.EmptyMap{} for _, dataType := range partColumnsDataTypes[i].Types { - isAggregationPresent = strings.HasPrefix(dataType, "AggregateFunction(") + isAggregationPresent = strings.Contains(dataType, "AggregateFunction(") if isAggregationPresent { + dataType = strings.TrimPrefix(dataType, "SimpleAggregateFunction(") dataType = strings.TrimPrefix(dataType, "AggregateFunction(") dataType = strings.TrimSuffix(dataType, ")") dataType = versioningAggregateRE.ReplaceAllString(dataType, "") diff --git a/pkg/clickhouse/clickhouse_test.go b/pkg/clickhouse/clickhouse_test.go index 34b93fac..ac2c07c3 100644 --- a/pkg/clickhouse/clickhouse_test.go +++ b/pkg/clickhouse/clickhouse_test.go @@ -32,9 +32,14 @@ func TestCheckTypesConsistency(t *testing.T) { Name: "Consistent data types", PartColumnsData: []ColumnDataTypes{ { - Column: "col2", + Column: "agg_col", Types: []string{"AggregateFunction(1, sumMap, Array(UInt16), Array(UInt64))", "AggregateFunction(sumMap, Array(UInt16), Array(UInt64))"}, }, + { + Column: "simple_agg_col", + Types: []string{"SimpleAggregateFunction(1, sum, UInt16)", "SimpleAggregateFunction(sum, UInt16)"}, + }, + { Column: "col3", Types: []string{"Nullable(Int32)", "Int32"}, @@ -68,12 +73,22 @@ func TestCheckTypesConsistency(t *testing.T) { Name: "Inconsistent AggregateFunction", PartColumnsData: []ColumnDataTypes{ { - Column: "col2", + Column: "agg_col", Types: []string{"AggregateFunction(1, avg, Array(UInt16), Array(UInt64))", "AggregateFunction(sumMap, Array(UInt16), Array(UInt64))"}, }, }, ExpectedError: expectedErr, }, + { + Name: "Inconsistent SimpleAggregateFunction", + PartColumnsData: []ColumnDataTypes{ + { + Column: "simple_agg_col", + Types: []string{"SimpleAggregateFunction(1, sum, UInt16)", "SimpleAggregateFunction(sumMap, Array(UInt16))"}, + }, + }, + ExpectedError: expectedErr, + }, { Name: "Inconsistent Types #2", PartColumnsData: []ColumnDataTypes{