[ 
https://issues.apache.org/jira/browse/CASSANDRA-17181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17453666#comment-17453666
 ] 

Bartlomiej edited comment on CASSANDRA-17181 at 12/5/21, 8:01 PM:
------------------------------------------------------------------

Hi [~blerer], I wanted to work on that, so I looked at the source code first, I 
am not sure if this
{code:java}
In 3.0 and 3.11 the code use to generate the schema.cql file is in 
TableCQLHelper and the unit tests in TableCQLHelperTest {code}
is true. In *cassandra-3.11* (also true in {*}cassandra-3.0{*}) branch I see 
that there is no TableCQLHelper class and instead of TableCQLHelperTest, 
ColumnFamilyStoreCQLHelperTest exists, which (as far I understand) tests 
snapshot creation and also handle the case described in the ticket
{code:java}
String schema = 
Files.toString(cfs.getDirectories().getSnapshotSchemaFile(SNAPSHOT), 
Charset.defaultCharset());
assertTrue(schema.contains(String.format("CREATE TYPE IF NOT EXISTS %s.%s(a1 
varint, a2 varint, a3 varint);", keyspace(), typeA)));
assertTrue(schema.contains(String.format("CREATE TYPE IF NOT EXISTS %s.%s(a1 
varint, a2 varint, a3 varint);", keyspace(), typeA)));
{code}
can you hint me more about this issue - I am wrong or right ?
thanks !


was (Author: bkowalczyyk):
Hi [~blerer], I wanted to work on that, so I looked at the source code first, I 
am not sure if this
{code:java}
In 3.0 and 3.11 the code use to generate the schema.cql file is in 
TableCQLHelper and the unit tests in TableCQLHelperTest {code}
is true. In *cassandra-3.11* (also true in {*}cassandra-3.0{*}) branch I see 
that there is no TableCQLHelper class and instead of TableCQLHelperTest, 
ColumnFamilyStoreCQLHelperTest exists, which (as far I understand) tests 
snapshot creation and also handle the case described in the ticket
{code:java}
String schema = 
Files.toString(cfs.getDirectories().getSnapshotSchemaFile(SNAPSHOT), 
Charset.defaultCharset());
assertTrue(schema.contains(String.format("CREATE TYPE IF NOT EXISTS %s.%s(a1 
varint, a2 varint, a3 varint);", keyspace(), typeA)));
assertTrue(schema.contains(String.format("CREATE TYPE IF NOT EXISTS %s.%s(a1 
varint, a2 varint, a3 varint);", keyspace(), typeA)));
{code}

can you hint me more about this issue - I am wrong or right ?

> schema.cql should have IF NOT EXISTS for CREATE TYPE
> ----------------------------------------------------
>
>                 Key: CASSANDRA-17181
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17181
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Local/Snapshots
>            Reporter: Benjamin Lerer
>            Priority: Normal
>              Labels: AdventCalendar2021, lhf
>             Fix For: 3.0.x, 3.11.x, 4.0.x
>
>
> When a schema.cql is created during a snapshot, {{CREATE TYPE}} statements 
> are not created with {{IF NOT EXISTS}} as the {{CREATE TABLE}} statements. 
> This can cause some issues when using those statements during restore.
> Additional Information for newcomers:
> In 3.0 and 3.11 the code use to generate the {{schema.cql}} file is in 
> {{TableCQLHelper}} and the unit tests in {{TableCQLHelperTest}}.
> In 4.0 the bug does not exist anymore but the test {{SchemaCQLHelperTest}} 
> does not test the correct behavior  and the code could be simplified



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to