Dictionary 如何将Cassandra中的列映射到以键作为列名、以值作为列值的记录?

Dictionary 如何将Cassandra中的列映射到以键作为列名、以值作为列值的记录?,dictionary,pivot,cassandra-3.0,cql3,cqlsh,Dictionary,Pivot,Cassandra 3.0,Cql3,Cqlsh,我在Cassandra中定义了一个表。有一列是map数据类型。我希望在此列上实现Pivot,使键成为列名,与该键关联的值成为列的值。 有什么特别的方法可以做到这一点吗?我必须在CQL中定义UDF或UDA吗?表定义、数据和预期输出如下: create table test_data( ... id int, ... product_name text, ... machine_address text, ... test_i

我在Cassandra中定义了一个表。有一列是map数据类型。我希望在此列上实现Pivot,使键成为列名,与该键关联的值成为列的值。 有什么特别的方法可以做到这一点吗?我必须在CQL中定义UDF或UDA吗?表定义、数据和预期输出如下:

     create table test_data(
        ... id int,
        ... product_name text,
        ... machine_address text,
        ... test_id int,
        ... result map<text,text>,
        ... PRIMARY KEY (id));

``` Table Data:
      id   | machine_address | product_name | result                                                                                       | test_id
------+-----------------+--------------+----------------------------------------------------------------------------------------------+---------
 1101 |          AEI-T4 |        Saker | {'comment': 'Pass', 'start_time': '2018-02-06T00:00:00', 'stop_time': '2018-02-06T00:00:00'} |     124
 1103 |          AEI-T5 |       Saker2 | {'comment': 'Pass', 'start_time': '2018-05-07T00:60:00', 'stop_time': '2018-06-07T00:00:00'} |     141
 1102 |          AEI-T4 |       Saker1 | {'comment': 'Fail', 'start_time': '2018-02-07T00:60:00', 'stop_time': '2018-02-07T00:00:00'} |     124

The expected output after implementing Pivot on the map column 'result' should be like:

start_time          | stop_time           | comment
------+-----------------+--------------+------------
2018-02-06T00:00:00 | 2018-02-06T00:00:00 | Pass
2018-05-07T00:60:00 | 2018-06-07T00:00:00 | Pass
2018-02-07T00:60:00 | 2018-02-07T00:00:00 | Fail
创建表测试数据(
…id int,
…产品名称文本,
…机器地址文本,
…测试id int,
…结果图,
…主键(id));
```表数据:
id |机器|地址|产品|名称|结果|测试| id
------+-----------------+--------------+----------------------------------------------------------------------------------------------+---------
1101 | AEI-T4 | Saker |{‘评论’:‘通过’、‘开始时间’:‘2018-02-06T00:00:00’、‘停止时间’:‘2018-02-06T00:00:00’}124
1103 | AEI-T5 | Saker2 |{‘评论’:‘通过’、‘开始时间’:‘2018-05-07T00:60:00’、‘停止时间’:‘2018-06-07T00:00:00’}141
1102 | AEI-T4 | Saker1 |{‘评论’:‘失败’,‘开始时间’:‘2018-02-07T00:60:00’,‘停止时间’:‘2018-02-07T00:00:00’}124
在映射列“result”上实现Pivot后的预期输出应如下所示:
开始时间|停止时间|评论
------+-----------------+--------------+------------
2018-02-06T00:00:00 | 2018-02-06T00:00:00 |通行证
2018-05-07T00:60:00 | 2018-06-07T00:00:00 |通过
2018-02-07T00:60:00 | 2018-02-07T00:00:00 |失败