Skip to content

Commit

Permalink
Merge pull request #21 from bruin-data/feature/remove-bruin-section
Browse files Browse the repository at this point in the history
fix empty materialization and add test
  • Loading branch information
albertobruin authored Mar 13, 2024
2 parents 7973856 + 34b0eba commit 7e2f41c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/pipeline/materializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Materializer struct {
func (m *Materializer) Render(asset *Asset, query string) (string, error) {
mat := asset.Materialization
if mat.Type == MaterializationTypeNone {
return query, nil
return removeComments(query), nil
}

if matFunc, ok := m.MaterializationMap[mat.Type][mat.Strategy]; ok {
Expand All @@ -35,6 +35,6 @@ func (m *Materializer) Render(asset *Asset, query string) (string, error) {
func removeComments(query string) string {
bytes := []byte(query)
re := regexp.MustCompile("(?s)/\\*.*?\\*/")
newBytes := re.ReplaceAll(bytes, nil)
newBytes := re.ReplaceAll(bytes, []byte(""))
return string(newBytes)
}
2 changes: 1 addition & 1 deletion pkg/pipeline/materializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestMaterializer_Render(t *testing.T) {
},
}

query := "SELECT * FROM table"
query := "/* @bruin some yaml @bruin*/SELECT * FROM table"
expected := "SELECT * FROM table"

result, err := materializer.Render(asset, query)
Expand Down

0 comments on commit 7e2f41c

Please sign in to comment.