I have a table that contains the data that for each product, they have certain attributes, say (limited to A,B,C for now). and I have the value corresponding to each attribute.
I'm not aware of a pivot
function in Hive but this is possible. You will need to collect attribute and value to a map, which can be done using this UDAF
Example:
ADD JAR /root/path/to/jar/brickhouse-0.7.0.jar;
CREATE TEMPORARY FUNCTION collect AS 'brickhouse.udf.collect.CollectUDAF';
SELECT product
, attr_map['A'] AS A
, attr_map['B'] AS B
, attr_map['C'] AS C
FROM (
SELECT product
, collect(attribute, value) AS attr_map
FROM test
GROUP BY product
) x
The caveat here is that if you have a lot of attributes, this can be quite a bit of repetitive code.