diff --git a/dbutil/rewrite.go b/dbutil/rewrite.go index 943e9b1..b6b839f 100644 --- a/dbutil/rewrite.go +++ b/dbutil/rewrite.go @@ -11,6 +11,7 @@ import ( // RewriteTable rewrites src table to dst table. // Rows can be transformed using the transform function. +// If row map is empty after transformation the row is skipped. // Additional options can be passed to modify the insert query. func RewriteTable(session gocqlx.Session, dst, src *table.Table, transform func(map[string]interface{}), options ...func(q *gocqlx.Queryx)) error { insert := dst.InsertQuery(session) @@ -28,6 +29,9 @@ func RewriteTable(session gocqlx.Session, dst, src *table.Table, transform func( if transform != nil { transform(m) } + if len(m) == 0 { + continue // map is empty - no need to clean + } if err := insert.BindMap(m).Exec(); err != nil { return err }