Hive から Cassandra へのマッピングを通じてデータを表示できない

Hive から Cassandra へのマッピングを通じてデータを表示できない

Sqoop 経由で Oracle DB から Cassandra にデータをロードした後、Cassandra と Hive の両方でデータを表示できました。その際、それぞれに 2 つのファイルが生成され、スペースの問題が発生すると言われました。この問題を解決するために、Hive のテーブルを削除し、外部テーブルを作成して Cassandra の列ファミリーにマップしました。しかし、Hive テーブルのデータを表示できません。Datastax Enterprise 3.0.1 を使用しています。Sqoop を使用して、Oracle DB のテーブル「test」をキースペース「test_keyspace」内の同じ名前の Cassandra 列ファミリーに移行しました。cassandra-cli コマンド list test; を使用してデータを表示できます。

cqlsh で列ファミリを記述すると、次の結果が得られます。

CREATE TABLE test (
rowkey text PRIMARY KEY,
bar text,
gump bigint,
home text,
note text,
pay text
) WITH
comment='' AND
comparator=text AND
read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
default_validation=text AND
min_compaction_threshold=4 AND
max_compaction_threshold=32 AND
replication_on_write='true' AND
compaction_strategy_class='SizeTieredCompactionStrategy' AND compression_parameters:stable_compression='SnappyCompressor';

Hive テーブルを作成するために使用しているコマンドは次のとおりです。

CREATE external TABLE test (
rowkey string,
bar string,
gump string,
home string,
note string,
pay string
)
STORED BY 'org.apache.hadoop.hive.cassandra.CassandraStorageHandler'
TBLPROPERTIES ( "cassandra.ks.name" = "test_keyspace" );

Hive で「show tables」と入力すると、テーブルがリストされます。ただし、「select * from test」では、行キーを除くテーブル内のすべての値が NULL として表示されます。

誰か解決策を知っていますか?

答え1

次のようにテーブルを作成してみてください。

CREATE external TABLE test (
    rowkey string,
    bar string,
    gump string,
    home string,
    note string,
    pay string
)
STORED BY 'org.apache.hadoop.hive.cassandra.CassandraStorageHandler'
WITH SERDEPROPERTIES("cql.primarykey"="rowkey"
TBLPROPERTIES ( "cassandra.ks.name" = "test_keyspace", "cassandra.cql.type"="text, text, text, text, text, text" );

関連情報