Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions pkg/targets/clickhouse/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,36 @@ func TestGenerateTagsTableQuery(t *testing.T) {
inTagNames []string
inTagTypes []string
out string
}{{
inTagNames: []string{"tag1"},
inTagTypes: []string{"string"},
out: "CREATE TABLE tags(\n" +
"created_date Date DEFAULT today(),\n" +
"created_at DateTime DEFAULT now(),\n" +
"id UInt32,\n" +
"tag1 Nullable(String)" +
") ENGINE = MergeTree(created_date, (id), 8192)"}, {
inTagNames: []string{"tag1", "tag2", "tag3", "tag4"},
inTagTypes: []string{"int32", "int64", "float32", "float64"},
out: "CREATE TABLE tags(\n" +
"created_date Date DEFAULT today(),\n" +
"created_at DateTime DEFAULT now(),\n" +
"id UInt32,\n" +
"tag1 Nullable(Int32),\n" +
"tag2 Nullable(Int64),\n" +
"tag3 Nullable(Float32),\n" +
"tag4 Nullable(Float64)" +
") ENGINE = MergeTree(created_date, (id), 8192)"},
}{
{
inTagNames: []string{"tag1"},
inTagTypes: []string{"string"},
out: "CREATE TABLE tags(\n" +
"created_date Date DEFAULT today(),\n" +
"created_at DateTime DEFAULT now(),\n" +
"id UInt32,\n" +
"tag1 Nullable(String)" +
") ENGINE = MergeTree()\n" +
"PARTITION BY created_date\n" +
"ORDER BY (id)\n" +
"SETTINGS index_granularity = 8192",
},
{
inTagNames: []string{"tag1", "tag2", "tag3", "tag4"},
inTagTypes: []string{"int32", "int64", "float32", "float64"},
out: "CREATE TABLE tags(\n" +
"created_date Date DEFAULT today(),\n" +
"created_at DateTime DEFAULT now(),\n" +
"id UInt32,\n" +
"tag1 Nullable(Int32),\n" +
"tag2 Nullable(Int64),\n" +
"tag3 Nullable(Float32),\n" +
"tag4 Nullable(Float64)" +
") ENGINE = MergeTree()\n" +
"PARTITION BY created_date\n" +
"ORDER BY (id)\n" +
"SETTINGS index_granularity = 8192",
},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("tags table for %v", tc.inTagNames), func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/targets/timescaledb/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func TestExtractTagNamesAndTypes(t *testing.T) {

}
}

func TestGenerateTagsTableQuery(t *testing.T) {
testCases := []struct {
in []string
Expand Down