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

Yifan Cai commented on CASSANDRA-15857:
---------------------------------------

I can confirm that in 4.0, non-frozen UDT cannot be ever dropped. So it is safe 
to freeze a tuple unconditionally.
{code:java}
[cqlsh 5.0.1 | Cassandra 4.0-beta1-SNAPSHOT | CQL spec 3.4.5 | Native protocol 
v4]
cqlsh> CREATE TYPE ks.some_type ( i int, t text );
cqlsh> CREATE TABLE ks.t ( pk int primary key, t some_type);
cqlsh> ALTER TABLE ks.t DROP t;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot 
drop non-frozen column t of user type some_type"
{code}
An optional [commit (freeze tuples 
unconditionally)|https://github.com/apache/cassandra/pull/669/commits/5e7577141de4ebe2c5c284fd7c22d0dd8f49aea0]
 was added to the patch. We can totally drop the commit if not like it. 
 All raw tuples are now always frozen. Because of that, rejections on frozen 
raw tuple in CreateFunctionStatement and CreateAggregateStatement are removed.

The rejections were added mainly to make the aggregate and function flexible to 
both frozen and non-frozen types, according to comments in CASSANDRA-9186. It 
prevents adding frozen in the declaration of aggregate and function, in order 
to not confuse users.

Given that tuples are always frozen, user should be clear that 'tuple' and 
'frozen tuple' produce the same effect. Therefore, it could be confusion-free 
to allow both form for tuple in the create statements for aggregates and 
functions.

> Frozen RawTuple is not annotated with frozen in the toString method
> -------------------------------------------------------------------
>
>                 Key: CASSANDRA-15857
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15857
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Legacy/CQL
>            Reporter: Yifan Cai
>            Assignee: Yifan Cai
>            Priority: Normal
>             Fix For: 4.0, 3.11.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> All raw types (e.g. RawCollection, RawUT) that supports freezing wraps the 
> type name with 'frozen<>' in the toString method, except RawTuple.
> Therefore, the RawTuple::toString output misses the frozen wrapper.
> Tuple is always frozen. However since CASSANDRA-15035, it throws when the 
> inner tuple is not explicitly wrapped with frozen within a collection.
> The method, CQL3Type.Raw::toString, is referenced at multiple places in the 
> source. For example, referenced in CreateTypeStatement.Raw and involved in 
> CQLSSTableWriter. Another example is that it is called to produce the 
> SchemaChange at several AlterSchemaStatement implementations.
> A test can prove that missing the frozen wrapper causes exception when 
> building CQLSSTableWriter for user types defined like below. Note that the 
> inner tuple is wrapped with frozen in the initial CQL statement.
> {code:java}
> CREATE TYPE ks.fooType ( f list<frozen<tuple<text, text>>> )
> {code}
> {code:java}
> org.apache.cassandra.exceptions.InvalidRequestException: Non-frozen tuples 
> are not allowed inside collections: list<tuple<text, text>>
>       at 
> org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.throwNestedNonFrozenError(CQL3Type.java:710)
>       at 
> org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.prepare(CQL3Type.java:669)
>       at 
> org.apache.cassandra.cql3.CQL3Type$Raw$RawCollection.prepareInternal(CQL3Type.java:661)
>       at 
> org.apache.cassandra.schema.Types$RawBuilder$RawUDT.lambda$prepare$1(Types.java:341)
>       at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>       at 
> java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
>       at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>       at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>       at 
> java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
>       at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>       at 
> java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
>       at 
> org.apache.cassandra.schema.Types$RawBuilder$RawUDT.prepare(Types.java:342)
>       at org.apache.cassandra.schema.Types$RawBuilder.build(Types.java:291)
>       at 
> org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.createTypes(CQLSSTableWriter.java:551)
>       at 
> org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.build(CQLSSTableWriter.java:527)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to