Cassandra 更改列类型:哪些类型兼容? [英] Cassandra alter column type: which types are compatible?

查看:22
本文介绍了Cassandra 更改列类型:哪些类型兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网上有一些关于列类型无法更改的示例的零散信息.例如,在 DataStax 站点 有一个提及:

  • 更改聚类列的类型.
  • 更改列定义了一个索引.

或者,例如,这里提到不能转换uuidtimeuuid.并且根据我的个人经验,我无法将 text 更改为 timestamp(我们将日期以 ISO8601 格式存储为文本,这是项目时间线早期的一个不幸决定).>

但是,我找不到关于哪些类型可以转换为哪些类型,或者至少哪些类型不能转换为哪些类型的完整描述.有人知道吗?

解决方案

好问题!我不得不承认,我也对缺乏有关此文档的详尽文档感到有些惊讶.您的问题启发我进行了一些调查,并且还博客.

从本质上讲,这里是与 Cassandra 兼容的 CQL 类型的完整列表(使用 Cassandra 2.2.0):

  • ascii -> blob、文本、varchar
  • bigint -> blob、时间戳、varint
  • int -> blob、varint
  • text -> blob、varchar
  • 时间戳 -> bigint、blob、varint
  • timeuuid -> blob,UUID
  • varchar -> blob、文本

注意事项:

  • blob 很多,因为任何东西都可以转换为 blob.
  • cqlsh 允许您将 varint 转换为新的日期类型,但这是一个错误 (CASSANDRA-10027).不要真的尝试这样做.

There's some patchy information on the interwebs about some examples when column type can't be changed. For example, on the DataStax site there's a mention:

  • Changing the type of a clustering column.
  • Changing columns on which an index is defined.

Or, for example, here is mentioned that you can't convert uuid to timeuuid. And from my personal experience, I can't change text to timestamp (we store dates in ISO8601 format as text, an unfortunate decision early in the project timeline).

However, I can't find a full description of which types can be converted to which, or at least which types can't be converted to which. Does anyone know?

解决方案

Great question! I have to admit that I was a bit surprised at the lack of thorough documentation on this one, as well. Your question inspired me to do a little investigation and blog about it as well.

Essentially, here is a comprehensive list of Cassandra compatible CQL types (using Cassandra 2.2.0):

  • ascii -> blob, text, varchar
  • bigint -> blob, timestamp, varint
  • int -> blob, varint
  • text -> blob, varchar
  • timestamp -> bigint, blob, varint
  • timeuuid -> blob, UUID
  • varchar -> blob, text

Notes:

  • blob is in there a lot, because anything can be converted to a blob.
  • cqlsh allows you to convert a varint to the new date type, but this is a bug (CASSANDRA-10027). Don't actually try that.

这篇关于Cassandra 更改列类型:哪些类型兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆