diff --git a/CHANGES.txt b/CHANGES.txt index 9c834f3183..5705453ea2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.2.4 + * Fix SimpleDateType type compatibility (CASSANDRA-10027) * (Hadoop) fix splits calculation (CASSANDRA-10640) * (Hadoop) ensure that Cluster instances are always closed (CASSANDRA-10058) * (cqlsh) show partial trace if incomplete after max_trace_wait (CASSANDRA-7645) diff --git a/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java b/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java index 747709e1fc..6e435eeb3a 100644 --- a/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java +++ b/src/java/org/apache/cassandra/db/marshal/SimpleDateType.java @@ -69,7 +69,7 @@ public class SimpleDateType extends AbstractType @Override public boolean isValueCompatibleWithInternal(AbstractType otherType) { - return this == otherType || otherType == IntegerType.instance; + return this == otherType || otherType == Int32Type.instance; } public Term fromJSONObject(Object parsed) throws MarshalException diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java index 95380f4a2f..566c0ea587 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java @@ -200,4 +200,21 @@ public class AlterTest extends CQLTester assertInvalidSyntaxMessage("no viable alternative at input 'WITH'", stmt); } } + + /** + * tests CASSANDRA-10027 + */ + @Test + public void testAlterColumnTypeToDate() throws Throwable + { + createTable("CREATE TABLE %s (key int PRIMARY KEY, c1 int);"); + execute("INSERT INTO %s (key, c1) VALUES (1,1);"); + execute("ALTER TABLE %s ALTER c1 TYPE date;"); + assertRows(execute("SELECT * FROM %s"), row(1, 1)); + + createTable("CREATE TABLE %s (key int PRIMARY KEY, c1 varint);"); + execute("INSERT INTO %s (key, c1) VALUES (1,1);"); + assertInvalidMessage("Cannot change c1 from type varint to type date: types are incompatible.", + "ALTER TABLE %s ALTER c1 TYPE date;"); + } }