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

Sylvain Lebresne commented on CASSANDRA-6710:
---------------------------------------------

Frankly, I'd rather shelve that ticket for a while.

If you want to store multiple types in the same value, there is a very simple 
workaround with relatively little downsides: use a {{blob}}. Pretty much all 
drivers provide a simple way to serialize the existing C* types into blobs 
(they kind of must support it internally anyway for bound statements) and CQL 
even has a bunch of blob convertion functions (for when you're using cqlsh for 
instance), so it's not even that inconvenient to use.

I'm not saying that a union type would be a bad thing per-se (the "Approach 1" 
above since "Approach 2" gives basically nothing over blobs outside of some 
inefficiencies and I'm -1 on that), it has pros, but they are relatively small:
* some additional server side validation (that you only put something of one of 
the type you declared). It's nice, but if it's server validation we're worried 
about, then something like CASSANDRA-9745 (which won't require any driver 
support) would give us that too (and more).
* small user convenience: you'll be able to do {{UPDATE foo SET v = 2 ...}} 
instead of {{UPDATE foo SET v = intAsBlob(2) ...}}. Neat, but not a world of 
difference either.
* possibly nice driver support for those languages that have unions natively. 
Nice-to-have but far from all languages haves unions.

On the cons side however, on top of the server side work, this will require all 
drivers to support this. And while it may not be the hardest thing ever, we're 
already adding features that require driver support fairly quickly, which isn't 
easy on all drivers maintainer. This is also yet more one feature to learn in 
CQL for newcomers, making the language more complex at least in that sense. So, 
given that the advantages feels to me rather small compared to the work it'll 
requires of everyone to support it, I'd rather leave that on the back burner 
for now.

> Support union types
> -------------------
>
>                 Key: CASSANDRA-6710
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6710
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: API, Core
>            Reporter: Tupshin Harper
>            Priority: Minor
>              Labels: ponies
>             Fix For: 3.x
>
>
> I sometimes find myself wanting to abuse Cassandra datatypes when I want to 
> interleave two different types in the same column.
> An example is in CASSANDRA-6167 where an approach is to tag what would 
> normally be a numeric field with text indicating that it is special in some 
> ways.
> A more elegant approach would be to be able to explicitly define disjoint 
> unions in the style of Haskell's and Scala's Either types.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to