【发布时间】:2013-12-12 01:02:00
【问题描述】:
我正在尝试使用 hive 将数据映射并插入到 cassandra。两者都没有什么经验,我尝试阅读并遵循以下内容:http://www.datastax.com/docs/datastax_enterprise3.0/solutions/about_hive
据我了解,这就是我所做的:
-
我在 hive 中创建了一个外部表,使用 CassandraStorageHandler,使用 :key、:column 和 :value 特殊名称映射到正确的键空间和 cassandra 列:
CREATE EXTERNAL TABLE test_table (myproductid INT , mydate TIMESTAMP , quantity BIGINT ) STORED BY 'org.apache.hadoop.hive.cassandra.CassandraStorageHandler' WITH SERDEPROPERTIES ( "cassandra.ks.name" = "test", "cassandra.columns.mapping" = ":key,:column,:value"); -
我在 hive 中插入数据(没有具体说明):
INSERT OVERWRITE TABLE test_table SELECT anId, aTimestamp, COUNT(*) FROM myDataTable GROUP BY anId, aTimestamp;
一切似乎都从 Hive 中找到,表描述正确,数据按预期显示在表中。
来自 Cassandra,DESCRIBE test_table 显示:
CREATE TABLE test_table (
key blob,
column1 blob,
value blob,
PRIMARY KEY (key, column1)
) WITH COMPACT STORAGE AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
数据没有输入,如果我SELECT它,它显示为二进制数据:
0x3238373639 | 0x323031332d30312d30322030303a30303a3030 | 0x31
我尝试按照文档添加到 SERDEPROPERTIES:
"cassandra.cf.validatorType" = "Int32Type, DateType, LongType"
还有:
"cassandra.cql3.type" = "int, timestamp, bigint"
但没有变化。
我阅读了更多文档,特别是有关用于转换数据类型的 UDF,但如果不是必需的,我想避免这种开销。
我错过了什么吗?是我遗漏了一步还是做的不对?
谢谢!
【问题讨论】:
标签: cassandra hive datastax-enterprise