Skip to content

Commit b295556

Browse files
Aleksandr.Bykovpenberg
Aleksandr.Bykov
authored andcommitted
Fix query create mv
Gemini could failed with error: Error: unable to create schema: unable to apply mutations to the test store: [cluster = test, query = 'CREATE MATERIALIZED VIEW ks1.table1_mv_0 AS SELECT * FROM ks1.table1 WHERE col10 IS NOT NULL AND pk0 IS NOT NULL AND pk1 IS NOT NULL AND pk2 IS NOT NULL AND pk3 IS NOT NULL AND ck0 IS NOT NULL AND ck1 IS NOT NULL AND ck2 IS NOT NULL PRIMARY KEY ((col10,pk0,pk1,pk2,pk3),ck0,ck1,ck2)']: Cannot add already existing table "table1_mv_0" to keyspace "ks1" Add to query "IF NOT EXISTS" "CREATE MATERIALIZED VIEW IF NOT EXISTS %s.%s AS SELECT * FROM %s.%s WHERE %s PRIMARY KEY"
1 parent e001470 commit b295556

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: schema.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,9 @@ func (s *Schema) GetCreateSchema() []string {
582582
}
583583
var createMaterializedView string
584584
if len(mv.PartitionKeys) == 1 {
585-
createMaterializedView = "CREATE MATERIALIZED VIEW %s.%s AS SELECT * FROM %s.%s WHERE %s PRIMARY KEY (%s"
585+
createMaterializedView = "CREATE MATERIALIZED VIEW IF NOT EXISTS %s.%s AS SELECT * FROM %s.%s WHERE %s PRIMARY KEY (%s"
586586
} else {
587-
createMaterializedView = "CREATE MATERIALIZED VIEW %s.%s AS SELECT * FROM %s.%s WHERE %s PRIMARY KEY ((%s)"
587+
createMaterializedView = "CREATE MATERIALIZED VIEW IF NOT EXISTS %s.%s AS SELECT * FROM %s.%s WHERE %s PRIMARY KEY ((%s)"
588588
}
589589
createMaterializedView = createMaterializedView + ",%s)"
590590
stmts = append(stmts, fmt.Sprintf(createMaterializedView,

0 commit comments

Comments
 (0)