From 8d1dead9879065ed346759eb3d46dec9fe614aa0 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Wed, 7 Aug 2024 12:52:52 +0200 Subject: [PATCH] Add merge to qtag instances in builder (#20) --- go/cmd/declarations/declarations.go | 6 ++++ go/pkg/qtag/builder_test.go | 13 +++++++ go/pkg/qtag/generated.go | 56 +++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/go/cmd/declarations/declarations.go b/go/cmd/declarations/declarations.go index 96aec04..d01058f 100644 --- a/go/cmd/declarations/declarations.go +++ b/go/cmd/declarations/declarations.go @@ -69,6 +69,12 @@ func (c *{{.ClassName}}) Format() (string, error) { func (c *{{.ClassName}}) UnknownValue(name string, value any) { c.values[name] = value } + +func (c *{{.ClassName}}) Merge(other *{{.ClassName}}) { + for k, v := range other.values { + c.values[k] = v + } +} ` // Template for generating methods diff --git a/go/pkg/qtag/builder_test.go b/go/pkg/qtag/builder_test.go index ea1d024..737128b 100644 --- a/go/pkg/qtag/builder_test.go +++ b/go/pkg/qtag/builder_test.go @@ -13,3 +13,16 @@ func TestInit(t *testing.T) { assert.NoError(t, err) assert.Equal(t, `{"app":"dbt","connection_name":"x"}`, s) } + +func TestMerge(t *testing.T) { + var x = NewDbt() + x.AddConnection_name("x") + x.AddNode_id("bob") + var y = NewDbt() + y.AddConnection_name("xx") + y.AddIs_incremental(false) + x.Merge(y) + s, err := x.Format() + assert.NoError(t, err) + assert.Equal(t, `{"app":"dbt","connection_name":"xx","is_incremental":false,"node_id":"bob"}`, s) +} diff --git a/go/pkg/qtag/generated.go b/go/pkg/qtag/generated.go index 8f6d300..fe3074d 100644 --- a/go/pkg/qtag/generated.go +++ b/go/pkg/qtag/generated.go @@ -32,6 +32,12 @@ func (c *Dbt) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Dbt) Merge(other *Dbt) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Dbt) AddApp(value any) { c.values["app"] = value } @@ -164,6 +170,12 @@ func (c *Hex) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Hex) Merge(other *Hex) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Hex) AddCategories(value any) { c.values["categories"] = value } @@ -220,6 +232,12 @@ func (c *Metabase) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Metabase) Merge(other *Metabase) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Metabase) AddClient(value any) { c.values["client"] = value } @@ -288,6 +306,12 @@ func (c *Mode) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Mode) Merge(other *Mode) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Mode) AddUser(value any) { c.values["user"] = value } @@ -332,6 +356,12 @@ func (c *Sigma) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Sigma) Merge(other *Sigma) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Sigma) AddKind(value any) { c.values["kind"] = value } @@ -376,6 +406,12 @@ func (c *Sundeck) UnknownValue(name string, value any) { c.values[name] = value } +func (c *Sundeck) Merge(other *Sundeck) { + for k, v := range other.values { + c.values[k] = v + } +} + func (c *Sundeck) AddApp(value any) { c.values["app"] = value } @@ -435,3 +471,23 @@ func (c *Sundeck) AddWorkload(value any) { func (c *Sundeck) AddKind(value any) { c.values["kind"] = value } + +func (c *Sundeck) AddAuto_routing_matched(value any) { + c.values["auto_routing_matched"] = value +} + +func (c *Sundeck) AddAuto_routing_matched_warehouse(value any) { + c.values["auto_routing_matched_warehouse"] = value +} + +func (c *Sundeck) AddAuto_routing_matched_warehouse_size(value any) { + c.values["auto_routing_matched_warehouse_size"] = value +} + +func (c *Sundeck) AddAuto_routing_num_computed_signatures(value any) { + c.values["auto_routing_num_computed_signatures"] = value +} + +func (c *Sundeck) AddAuto_routing_warehouse_pool(value any) { + c.values["auto_routing_warehouse_pool"] = value +}