git commit: Fix ReversedType.isCompatibleWith()

2014-08-20 Thread tylerhobbs
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 4fc417c40 - a4e108c40


Fix ReversedType.isCompatibleWith()

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-7797


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a4e108c4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a4e108c4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a4e108c4

Branch: refs/heads/cassandra-2.0
Commit: a4e108c40b234fa754a56a21b63635b83f90aceb
Parents: 4fc417c
Author: Tyler Hobbs ty...@datastax.com
Authored: Wed Aug 20 10:58:54 2014 -0500
Committer: Tyler Hobbs ty...@datastax.com
Committed: Wed Aug 20 11:01:28 2014 -0500

--
 CHANGES.txt |  2 ++
 .../cassandra/db/marshal/ReversedType.java  |  9 ++
 .../org/apache/cassandra/cql3/TypeTest.java | 34 
 3 files changed, 45 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index fe9f4e0..94bdd89 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Fix ALTER clustering column type from DateType to TimestampType when
+   using DESC clustering order (CASSANRDA-7797)
  * Stop inheriting liveRatio and liveRatioComputedAt from previous
memtables (CASSANDRA-7796)
  * Throw EOFException if we run out of chunks in compressed datafile

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/src/java/org/apache/cassandra/db/marshal/ReversedType.java
--
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java 
b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index cd61bbe..ffb0229 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -84,6 +84,15 @@ public class ReversedTypeT extends AbstractTypeT
 }
 
 @Override
+public boolean isCompatibleWith(AbstractType? otherType)
+{
+if (!(otherType instanceof ReversedType))
+return false;
+
+return this.baseType.isCompatibleWith(((ReversedType) 
otherType).baseType);
+}
+
+@Override
 public boolean isValueCompatibleWith(AbstractType? otherType)
 {
 return this.baseType.isValueCompatibleWith(otherType);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/test/unit/org/apache/cassandra/cql3/TypeTest.java
--
diff --git a/test/unit/org/apache/cassandra/cql3/TypeTest.java 
b/test/unit/org/apache/cassandra/cql3/TypeTest.java
index f911a44..b08ca2c 100644
--- a/test/unit/org/apache/cassandra/cql3/TypeTest.java
+++ b/test/unit/org/apache/cassandra/cql3/TypeTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.gms.Gossiper;
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.cql3.QueryProcessor.process;
 import static org.apache.cassandra.cql3.QueryProcessor.processInternal;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class TypeTest
 {
@@ -141,4 +143,36 @@ public class TypeTest
 results = executePrepared(prepare(select), QueryOptions.DEFAULT);
 assertEquals(2, results.size());
 }
+
+@Test
+// tests CASSANDRA-7797
+public void testAlterReversedColumn() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS %s.test_alter_reversed 
(a int, b 'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH 
CLUSTERING ORDER BY (b DESC));
+executeSchemaChange(ALTER TABLE %s.test_alter_reversed ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimestampType)');
+}
+
+@Test
+public void testIncompatibleReversedTypes() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS 
%s.test_incompatible_reversed (a int, b 
'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH CLUSTERING 
ORDER BY (b DESC));
+try
+{
+executeSchemaChange(ALTER TABLE %s.test_incompatible_reversed 
ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)');
+fail(Expected error for ALTER statement);
+}
+   

[1/2] git commit: Fix ReversedType.isCompatibleWith()

2014-08-20 Thread tylerhobbs
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1.0 45159ae7b - d3450570c


Fix ReversedType.isCompatibleWith()

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-7797


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a4e108c4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a4e108c4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a4e108c4

Branch: refs/heads/cassandra-2.1.0
Commit: a4e108c40b234fa754a56a21b63635b83f90aceb
Parents: 4fc417c
Author: Tyler Hobbs ty...@datastax.com
Authored: Wed Aug 20 10:58:54 2014 -0500
Committer: Tyler Hobbs ty...@datastax.com
Committed: Wed Aug 20 11:01:28 2014 -0500

--
 CHANGES.txt |  2 ++
 .../cassandra/db/marshal/ReversedType.java  |  9 ++
 .../org/apache/cassandra/cql3/TypeTest.java | 34 
 3 files changed, 45 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index fe9f4e0..94bdd89 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Fix ALTER clustering column type from DateType to TimestampType when
+   using DESC clustering order (CASSANRDA-7797)
  * Stop inheriting liveRatio and liveRatioComputedAt from previous
memtables (CASSANDRA-7796)
  * Throw EOFException if we run out of chunks in compressed datafile

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/src/java/org/apache/cassandra/db/marshal/ReversedType.java
--
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java 
b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index cd61bbe..ffb0229 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -84,6 +84,15 @@ public class ReversedTypeT extends AbstractTypeT
 }
 
 @Override
+public boolean isCompatibleWith(AbstractType? otherType)
+{
+if (!(otherType instanceof ReversedType))
+return false;
+
+return this.baseType.isCompatibleWith(((ReversedType) 
otherType).baseType);
+}
+
+@Override
 public boolean isValueCompatibleWith(AbstractType? otherType)
 {
 return this.baseType.isValueCompatibleWith(otherType);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/test/unit/org/apache/cassandra/cql3/TypeTest.java
--
diff --git a/test/unit/org/apache/cassandra/cql3/TypeTest.java 
b/test/unit/org/apache/cassandra/cql3/TypeTest.java
index f911a44..b08ca2c 100644
--- a/test/unit/org/apache/cassandra/cql3/TypeTest.java
+++ b/test/unit/org/apache/cassandra/cql3/TypeTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.gms.Gossiper;
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.cql3.QueryProcessor.process;
 import static org.apache.cassandra.cql3.QueryProcessor.processInternal;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class TypeTest
 {
@@ -141,4 +143,36 @@ public class TypeTest
 results = executePrepared(prepare(select), QueryOptions.DEFAULT);
 assertEquals(2, results.size());
 }
+
+@Test
+// tests CASSANDRA-7797
+public void testAlterReversedColumn() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS %s.test_alter_reversed 
(a int, b 'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH 
CLUSTERING ORDER BY (b DESC));
+executeSchemaChange(ALTER TABLE %s.test_alter_reversed ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimestampType)');
+}
+
+@Test
+public void testIncompatibleReversedTypes() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS 
%s.test_incompatible_reversed (a int, b 
'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH CLUSTERING 
ORDER BY (b DESC));
+try
+{
+executeSchemaChange(ALTER TABLE %s.test_incompatible_reversed 
ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)');
+fail(Expected error for ALTER statement);
+}

[1/3] git commit: Fix ReversedType.isCompatibleWith()

2014-08-20 Thread tylerhobbs
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 cc79fe1a1 - 8d494c782


Fix ReversedType.isCompatibleWith()

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-7797


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a4e108c4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a4e108c4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a4e108c4

Branch: refs/heads/cassandra-2.1
Commit: a4e108c40b234fa754a56a21b63635b83f90aceb
Parents: 4fc417c
Author: Tyler Hobbs ty...@datastax.com
Authored: Wed Aug 20 10:58:54 2014 -0500
Committer: Tyler Hobbs ty...@datastax.com
Committed: Wed Aug 20 11:01:28 2014 -0500

--
 CHANGES.txt |  2 ++
 .../cassandra/db/marshal/ReversedType.java  |  9 ++
 .../org/apache/cassandra/cql3/TypeTest.java | 34 
 3 files changed, 45 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index fe9f4e0..94bdd89 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Fix ALTER clustering column type from DateType to TimestampType when
+   using DESC clustering order (CASSANRDA-7797)
  * Stop inheriting liveRatio and liveRatioComputedAt from previous
memtables (CASSANDRA-7796)
  * Throw EOFException if we run out of chunks in compressed datafile

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/src/java/org/apache/cassandra/db/marshal/ReversedType.java
--
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java 
b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index cd61bbe..ffb0229 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -84,6 +84,15 @@ public class ReversedTypeT extends AbstractTypeT
 }
 
 @Override
+public boolean isCompatibleWith(AbstractType? otherType)
+{
+if (!(otherType instanceof ReversedType))
+return false;
+
+return this.baseType.isCompatibleWith(((ReversedType) 
otherType).baseType);
+}
+
+@Override
 public boolean isValueCompatibleWith(AbstractType? otherType)
 {
 return this.baseType.isValueCompatibleWith(otherType);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/test/unit/org/apache/cassandra/cql3/TypeTest.java
--
diff --git a/test/unit/org/apache/cassandra/cql3/TypeTest.java 
b/test/unit/org/apache/cassandra/cql3/TypeTest.java
index f911a44..b08ca2c 100644
--- a/test/unit/org/apache/cassandra/cql3/TypeTest.java
+++ b/test/unit/org/apache/cassandra/cql3/TypeTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.gms.Gossiper;
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.cql3.QueryProcessor.process;
 import static org.apache.cassandra.cql3.QueryProcessor.processInternal;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class TypeTest
 {
@@ -141,4 +143,36 @@ public class TypeTest
 results = executePrepared(prepare(select), QueryOptions.DEFAULT);
 assertEquals(2, results.size());
 }
+
+@Test
+// tests CASSANDRA-7797
+public void testAlterReversedColumn() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS %s.test_alter_reversed 
(a int, b 'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH 
CLUSTERING ORDER BY (b DESC));
+executeSchemaChange(ALTER TABLE %s.test_alter_reversed ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimestampType)');
+}
+
+@Test
+public void testIncompatibleReversedTypes() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS 
%s.test_incompatible_reversed (a int, b 
'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH CLUSTERING 
ORDER BY (b DESC));
+try
+{
+executeSchemaChange(ALTER TABLE %s.test_incompatible_reversed 
ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)');
+fail(Expected error for ALTER statement);
+}
+   

[1/4] git commit: Fix ReversedType.isCompatibleWith()

2014-08-20 Thread tylerhobbs
Repository: cassandra
Updated Branches:
  refs/heads/trunk c158efdf6 - 0f530413c


Fix ReversedType.isCompatibleWith()

Patch by Tyler Hobbs; reviewed by Sylvain Lebresne for CASSANDRA-7797


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a4e108c4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a4e108c4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a4e108c4

Branch: refs/heads/trunk
Commit: a4e108c40b234fa754a56a21b63635b83f90aceb
Parents: 4fc417c
Author: Tyler Hobbs ty...@datastax.com
Authored: Wed Aug 20 10:58:54 2014 -0500
Committer: Tyler Hobbs ty...@datastax.com
Committed: Wed Aug 20 11:01:28 2014 -0500

--
 CHANGES.txt |  2 ++
 .../cassandra/db/marshal/ReversedType.java  |  9 ++
 .../org/apache/cassandra/cql3/TypeTest.java | 34 
 3 files changed, 45 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index fe9f4e0..94bdd89 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.0.10
+ * Fix ALTER clustering column type from DateType to TimestampType when
+   using DESC clustering order (CASSANRDA-7797)
  * Stop inheriting liveRatio and liveRatioComputedAt from previous
memtables (CASSANDRA-7796)
  * Throw EOFException if we run out of chunks in compressed datafile

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/src/java/org/apache/cassandra/db/marshal/ReversedType.java
--
diff --git a/src/java/org/apache/cassandra/db/marshal/ReversedType.java 
b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
index cd61bbe..ffb0229 100644
--- a/src/java/org/apache/cassandra/db/marshal/ReversedType.java
+++ b/src/java/org/apache/cassandra/db/marshal/ReversedType.java
@@ -84,6 +84,15 @@ public class ReversedTypeT extends AbstractTypeT
 }
 
 @Override
+public boolean isCompatibleWith(AbstractType? otherType)
+{
+if (!(otherType instanceof ReversedType))
+return false;
+
+return this.baseType.isCompatibleWith(((ReversedType) 
otherType).baseType);
+}
+
+@Override
 public boolean isValueCompatibleWith(AbstractType? otherType)
 {
 return this.baseType.isValueCompatibleWith(otherType);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a4e108c4/test/unit/org/apache/cassandra/cql3/TypeTest.java
--
diff --git a/test/unit/org/apache/cassandra/cql3/TypeTest.java 
b/test/unit/org/apache/cassandra/cql3/TypeTest.java
index f911a44..b08ca2c 100644
--- a/test/unit/org/apache/cassandra/cql3/TypeTest.java
+++ b/test/unit/org/apache/cassandra/cql3/TypeTest.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.cql3;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.ConsistencyLevel;
+import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.RequestExecutionException;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.gms.Gossiper;
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.cql3.QueryProcessor.process;
 import static org.apache.cassandra.cql3.QueryProcessor.processInternal;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class TypeTest
 {
@@ -141,4 +143,36 @@ public class TypeTest
 results = executePrepared(prepare(select), QueryOptions.DEFAULT);
 assertEquals(2, results.size());
 }
+
+@Test
+// tests CASSANDRA-7797
+public void testAlterReversedColumn() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS %s.test_alter_reversed 
(a int, b 'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH 
CLUSTERING ORDER BY (b DESC));
+executeSchemaChange(ALTER TABLE %s.test_alter_reversed ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimestampType)');
+}
+
+@Test
+public void testIncompatibleReversedTypes() throws Throwable
+{
+executeSchemaChange(CREATE TABLE IF NOT EXISTS 
%s.test_incompatible_reversed (a int, b 
'org.apache.cassandra.db.marshal.DateType', PRIMARY KEY (a, b)) WITH CLUSTERING 
ORDER BY (b DESC));
+try
+{
+executeSchemaChange(ALTER TABLE %s.test_incompatible_reversed 
ALTER b TYPE 
'org.apache.cassandra.db.marshal.ReversedType(org.apache.cassandra.db.marshal.TimeUUIDType)');
+fail(Expected error for ALTER statement);
+}
+catch