Skip to content

Commit

Permalink
fix check_parts_columns corner cases for AggregateFunction and `S…
Browse files Browse the repository at this point in the history
…impleAggregateFunction` versioning, fix #819
  • Loading branch information
Slach committed Jan 30, 2024
1 parent 5be9d48 commit 66f6480
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down
19 changes: 17 additions & 2 deletions pkg/clickhouse/clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 66f6480

Please sign in to comment.