You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/12/01 08:45:08 UTC
[GitHub] [cassandra] djanand commented on a change in pull request #1319: modify alter statements with IF EXISTS and IF NOT EXISTS
djanand commented on a change in pull request #1319:
URL: https://github.com/apache/cassandra/pull/1319#discussion_r759965843
##########
File path: src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java
##########
@@ -93,7 +94,12 @@ public Keyspaces apply(Keyspaces schema) throws UnknownHostException
: keyspace.getTableOrViewNullable(tableName);
if (null == table)
+ {
+ if (ifTableExists)
+ return schema;
Review comment:
Looks like when using the above statement, i.e not returning `schema` would throw an exception when we try to alter a table that doesn't exist using `IF EXISTS`. For e.g consider this test case
```
@Test
public void testAlterTableWithoutCreateTableWithIfExists() throws Throwable
{
String tbl1 = KEYSPACE + "." + createTableName();
assertNull(execute(String.format("ALTER TABLE IF EXISTS %s ADD myCollection list<text>;", tbl1)));
}
```
would lead to
```
java.lang.NullPointerException
at org.apache.cassandra.cql3.statements.schema.AlterTableStatement.apply(AlterTableStatement.java:103)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org