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

Mohammad Suhel commented on CASSANDRA-21761:
--------------------------------------------

Hi, I have raised the PR against cassandra-5.0: 
[https://github.com/apache/cassandra/pull/5330]

The new and existing tests pass locally (AlterTest, LegacySSTableTest, 
UserTypesTest) and checkstyle is clean. 

I also verified it on a local node built from the branch.

Before the fix:
{noformat}
  Connected to Test Cluster at 127.0.0.2:9042
  [cqlsh 6.2.0 | Cassandra 5.0.10-SNAPSHOT | CQL spec 3.4.7 | Native protocol 
v5]
  Use HELP for help.
  cqlsh> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 
'replication_factor': 1};
  cqlsh> CREATE TYPE ks.udt (a int, b text);
  cqlsh> CREATE TABLE ks.t (p int PRIMARY KEY, x frozen<udt>);
  cqlsh> ALTER TABLE ks.t DROP x;
  cqlsh> ALTER TABLE ks.t ADD x frozen<udt>;
  InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot 
add a column 'x' of type frozen<udt>, incompatible with previously dropped 
column 'x' of type frozen<tuple<int, text>>"
  cqlsh> exit
  {noformat}
After the fix:
{noformat}
  Connected to Test Cluster at 127.0.0.2:9042
  [cqlsh 6.2.0 | Cassandra 5.0.10-SNAPSHOT | CQL spec 3.4.7 | Native protocol 
v5]
  Use HELP for help.
  cqlsh> CREATE KEYSPACE ks WITH replication = {'class': 'SimpleStrategy', 
'replication_factor': 1};
  cqlsh> CREATE TYPE ks.udt (a int, b text);
  cqlsh> CREATE TABLE ks.t (p int PRIMARY KEY, x frozen<udt>);
  cqlsh> ALTER TABLE ks.t DROP x;
  cqlsh> ALTER TABLE ks.t ADD x frozen<udt>;
  cqlsh> exit
  {noformat}

> Re-adding a dropped column with the same frozen user type is rejected as 
> incompatible
> -------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-21761
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21761
>             Project: Apache Cassandra
>          Issue Type: Bug
>          Components: Legacy/Local Write-Read Paths
>            Reporter: Nadav Har'El
>            Assignee: Mohammad Suhel
>            Priority: Normal
>             Fix For: 5.0.x, 6.x, 7.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> After dropping a column of a frozen user type, re-adding a column with the 
> same name and the *same* type fails:
> {code:sql}
> CREATE TYPE ks.udt (a int, b text);
> CREATE TABLE ks.t (p int PRIMARY KEY, x frozen<udt>);
> ALTER TABLE ks.t DROP x;
> ALTER TABLE ks.t ADD x frozen<udt>;
> {code}
> The last statement fails with:
> {noformat}
> InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot 
> add a column 'x' of type frozen<udt>, incompatible with previously dropped 
> column 'x' of type frozen<tuple<int, text>>"
> {noformat}
> Reproduced on Cassandra 5.0.9 and 6.0-alpha2.
> The cause: a dropped column's type is recorded with its user types expanded 
> into tuples ({{TableMetadata}}, {{column.type.expandUserTypes()}}), but 
> {{AlterTableStatement}} compares the new, unexpanded type with it using 
> {{isSerializationCompatibleWith()}}, and a {{UserType}} is not 
> value-compatible with a {{TupleType}}. Expanding the new type the same way 
> before the comparison would fix it.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to