mirror of https://github.com/apache/cassandra
Add more tests for CASSANDRA-16905
patch by Stefan Miklosovic; reviewed by Andres de la Peña for CASSANDRA-18760
This commit is contained in:
parent
f0280fb6f8
commit
65a3d36eb9
|
|
@ -35,6 +35,41 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class AlterTest extends CQLTester
|
||||
{
|
||||
@Test
|
||||
public void testNonFrozenCollectionsAreIncompatibleWithBlob() throws Throwable
|
||||
{
|
||||
String[] collectionTypes = new String[] {"map<int, int>", "set<int>", "list<int>"};
|
||||
|
||||
for (String type : collectionTypes)
|
||||
{
|
||||
createTable("CREATE TABLE %s (a int, b " + type + ", PRIMARY KEY (a));");
|
||||
alterTable("ALTER TABLE %s DROP b;");
|
||||
assertInvalidMessage("Cannot re-add previously dropped column 'b' of type blob, incompatible with previous type " + type,
|
||||
"ALTER TABLE %s ADD b blob;");
|
||||
}
|
||||
|
||||
for (String type : collectionTypes)
|
||||
{
|
||||
createTable("CREATE TABLE %s (a int, b blob, PRIMARY KEY (a));");
|
||||
alterTable("ALTER TABLE %s DROP b;");
|
||||
assertInvalidMessage("Cannot re-add previously dropped column 'b' of type " + type + ", incompatible with previous type blob",
|
||||
"ALTER TABLE %s ADD b " + type + ';');
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFrozenCollectionsAreCompatibleWithBlob()
|
||||
{
|
||||
String[] collectionTypes = new String[] {"frozen<map<int, int>>", "frozen<set<int>>", "frozen<list<int>>"};
|
||||
|
||||
for (String type : collectionTypes)
|
||||
{
|
||||
createTable("CREATE TABLE %s (a int, b " + type + ", PRIMARY KEY (a));");
|
||||
alterTable("ALTER TABLE %s DROP b;");
|
||||
alterTable("ALTER TABLE %s ADD b blob;");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddList() throws Throwable
|
||||
{
|
||||
|
|
@ -338,6 +373,27 @@ public class AlterTest extends CQLTester
|
|||
execute("ALTER TABLE %s RENAME c1 TO \"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidDroppingAndAddingOfCollections() throws Throwable
|
||||
{
|
||||
for (String[] typePair : new String[][]
|
||||
{
|
||||
new String[] {"list<int>", "list<varint>"},
|
||||
new String[] {"set<int>", "set<varint>"},
|
||||
new String[] {"map<int, int>", "map<varint, varint>"},
|
||||
new String[] {"list<int>", "frozen<list<varint>>"},
|
||||
new String[] {"set<int>", "frozen<set<varint>>"},
|
||||
new String[] {"map<int, int>", "frozen<map<varint, varint>>"},
|
||||
})
|
||||
{
|
||||
createTable("create table %s (k int, c int, v " + typePair[0] + ", PRIMARY KEY (k, c))");
|
||||
execute("alter table %s drop v");
|
||||
assertInvalidMessage("Cannot re-add previously dropped column 'v' of type "
|
||||
+ typePair[1] + ", incompatible with previous type " + typePair[0],
|
||||
"alter table %s add v " + typePair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = InvalidRequestException.class)
|
||||
public void testDropFixedAddVariable() throws Throwable
|
||||
{
|
||||
|
|
@ -346,14 +402,6 @@ public class AlterTest extends CQLTester
|
|||
execute("alter table %s add v varint");
|
||||
}
|
||||
|
||||
@Test(expected = InvalidRequestException.class)
|
||||
public void testDropFixedCollectionAddVariableCollection() throws Throwable
|
||||
{
|
||||
createTable("create table %s (k int, c int, v list<int>, PRIMARY KEY (k, c))");
|
||||
execute("alter table %s drop v");
|
||||
execute("alter table %s add v list<varint>");
|
||||
}
|
||||
|
||||
@Test(expected = InvalidRequestException.class)
|
||||
public void testDropSimpleAddComplex() throws Throwable
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue