[
https://issues.apache.org/jira/browse/CASSANDRA-16903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17432121#comment-17432121
]
Kanthi Subramanian commented on CASSANDRA-16903:
------------------------------------------------
[~blerer], can the logic be implemented in this function or is it in the ANTLR
parser. I was trying to figure out the parser.g (not an expert in antlr), just
couldnt figure out how the comparatorType only checks for native types.
Appreciate any help
{code:java}
// code placeholder
public Keyspaces apply(Keyspaces schema)
{
KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);
if (null == keyspace)
throw ire("Keyspace '%s' doesn't exist", keyspaceName);
UserType existingType = keyspace.types.getNullable(bytes(typeName));
if (null != existingType)
{
if (ifNotExists)
return schema;
throw ire("A user type with name '%s' already exists", typeName);
}
Set<FieldIdentifier> usedNames = new HashSet<>();
for (FieldIdentifier name : fieldNames)
if (!usedNames.add(name))
throw ire("Duplicate field name '%s' in type '%s'", name, typeName);
for (CQL3Type.Raw type : rawFieldTypes)
{
if (type.isCounter())
throw ire("A user type cannot contain counters");
if (type.isUDT() && !type.isFrozen())
throw ire("A user type cannot contain non-frozen UDTs");
}
List<AbstractType<?>> fieldTypes =
rawFieldTypes.stream()
.map(t -> t.prepare(keyspaceName,
keyspace.types).getType())
.collect(toList());
UserType udt = new UserType(keyspaceName, bytes(typeName), fieldNames,
fieldTypes, true);
return
schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.types.with(udt)));
}
{code}
> UDTs named after built-in data types
> ------------------------------------
>
> Key: CASSANDRA-16903
> URL: https://issues.apache.org/jira/browse/CASSANDRA-16903
> Project: Cassandra
> Issue Type: Bug
> Components: Feature/UDT
> Reporter: Brandon Bordeaux
> Assignee: Kanthi Subramanian
> Priority: Normal
> Fix For: 4.0.x
>
>
> Working with Cassandra 4.0 I found UDTs can be named after some built-in data
> type, like map, list, and tuple, but not for other types, like text or set.
> This behavior should be consistent across all built-in types where Cassandra
> shouldn't allow a UDT to be named after any built-in type.
> Having UDTs named after built-in types cause confusion working with table
> schemas and may introduce downstream issues when Cassandra works with these
> types.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]