Skip to content

Commit

Permalink
Add tests proving #2110 and #2495
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-asawicki committed Feb 23, 2024
1 parent 9a10cb1 commit 17f2f7b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/sdk/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,4 +1629,22 @@ func TestTable_GetClusterByKeys(t *testing.T) {

assert.Equal(t, []string{"abc", "def"}, table.GetClusterByKeys())
})

t.Run("with function with one param", func(t *testing.T) {
table := Table{ClusterBy: "LINEAR(some_func(some_param),other_param)"}

assert.Equal(t, []string{"some_func(some_param)", "other_param"}, table.GetClusterByKeys())
})

t.Run("with function with more than one param", func(t *testing.T) {
table := Table{ClusterBy: "LINEAR(date_trunc('HOUR',TIMESTAMP_HR),CLIENT_ID)"}

assert.Equal(t, []string{"date_trunc('HOUR',TIMESTAMP_HR)", "CLIENT_ID"}, table.GetClusterByKeys())
})

t.Run("with nested functions", func(t *testing.T) {
table := Table{ClusterBy: "LINEAR(some_func(some_param, some_other_param, other_func(some_param, some_other_param)),other_param)"}

assert.Equal(t, []string{"some_func(some_param, some_other_param, other_func(some_param, some_other_param))", "other_param"}, table.GetClusterByKeys())
})
}

0 comments on commit 17f2f7b

Please sign in to comment.