简体   繁体   中英

How to “GROUP BY” array column in Cratedb

For example I have the following script:

CREATE TABLE test 
(
     items  array(string)
)

INSERT INTO test (items) VALUES (array['a', 'b']);
INSERT INTO test (items) VALUES (array['a'])

Is it possible to count number of items in the table? Something similar to ES terms aggregation.

I expected something like this:

SELECT COUNT(\*), items 
FROM test 
GROUP BY items;

But this raises an error

Cannot GROUP BY 'items': invalid data type 'string_array'

As of CrateDB 1.0 this is not supported. See this GH issue and this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM