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

Stefan Miklosovic edited comment on CASSANDRA-20036 at 11/4/24 5:00 PM:
------------------------------------------------------------------------

[~dcapwell] not only UDTs are not included but they are not included when 
fields of an UDT are UDTs too. 

I added a test for reversed udt as clustering key with udts as fields to check 
that it is fixed.

BTW I am not sure about your comment about the incorrect order.

{code}
public Set<ByteBuffer> getReferencedUserTypes()
{
    Set<ByteBuffer> types = new LinkedHashSet<>();
    columns().forEach(c -> addUserTypes(c.type, types));
    return types;
}
{code}

If you notice, types is LinkedHashSet, that preserves insertion order. 

BTW this patch itself, while it fixes the problem you proposed, until 
CASSANDRA-20050 is merged then we will not be able to insert any data into such 
table. I think CASSANDRA-20050 should go first.


was (Author: smiklosovic):
[~dcapwell] not only UDTs are not included but they are not included when 
fields of an UDT are UDTs too. 

I added a test for reversed udt as clustering key with udts as fields to check 
that it is fixed.

BTW I am not sure about your comment about the incorrect order.

{code}
public Set<ByteBuffer> getReferencedUserTypes()
{
    Set<ByteBuffer> types = new LinkedHashSet<>();
    columns().forEach(c -> addUserTypes(c.type, types));
    return types;
}
{code}

If you notice, types is LinkedHashSet, that preserves insertion order. 

> When snapshotting the recreate CQL does not count UDTs from reverse 
> clustering columns
> --------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-20036
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20036
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Cluster/Schema, Local/Snapshots
>            Reporter: David Capwell
>            Assignee: Stefan Miklosovic
>            Priority: Normal
>             Fix For: 5.x
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> When we snapshot a table we create a list of CQL statements to recreate the 
> table, this tries to include the UDT creation as well, but fails to find all 
> UDTs!
> The bug is from 
> org.apache.cassandra.schema.TableMetadata#getReferencedUserTypes
> {code}
> public Set<ByteBuffer> getReferencedUserTypes()
> {
>     Set<ByteBuffer> types = new LinkedHashSet<>();
>     columns().forEach(c -> addUserTypes(c.type, types));
>     return types;
> }
> {code}
> c.type maybe ReverseType, so checking for UDT fails and the UDT does not get 
> included.
> The following would show this
> {code}
> CREATE TYPE foo (a int);
> CREATE TABLE tbl (pk int, ck frozen<foo>, PRIMARY KEY(pk, ck)) WITH 
> CLUSTERING ORDER BY (ck DESC).
> {code}
> Additionally, the order that the UDTs found are listed are not in correct 
> order, they are in random hash order…. This becomes a problem when the UDTs 
> depend on each other such as the following example
> {code}
> CREATE TYPE a (a int);
> CREATE TYPE b (b a);
> {code}
> In this example you must create “a” BEFORE “b”, but with hash ordering that 
> isn’t always true.
> Utilities exist in 
> test/unit/org/apache/cassandra/utils/CassandraGenerators.java to handle this 
> case properly



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to