Skip to content

Commit

Permalink
fix empty materialization and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
albertobruin committed Mar 13, 2024
1 parent 7973856 commit 34b0eba
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 34b0eba

Please sign in to comment.