· 9 years ago · Nov 24, 2016, 11:04 AM
1CREATE EXTERNAL TABLE IF NOT EXISTS events (
2random_id STRING, event_type STRING, country STRING, device STRING, parentID STRING,
3products ARRAY<STRING>, sessionID STRING, type STRING, indirect STRING, arrived_at STRING,
4time BIGINT, browser STRING, apikey STRING
5)
6ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
7LOCATION '/datos/Pruebas/input/';
8
9SELECT parentID, product, `event-type`, type, indirect, device, country, COUNT(*) count, apikey FROM events LATERAL VIEW explode(products) productsTable AS product GROUP BY parentID,productsTable.product, `event-type`, type, indirect, device, country, apikey ORDER BY count DESC;