I have a table contains data vertically (attr_name and attr_value columns) like below but I want to print the data vertically. Is it possible in Hive?
+------------------------+--------+--------+---------------+------------+
|relation |object |instance|attr_name |attr_value |
+------------------------+--------+--------+---------------+------------+
|Summary~>Disk~>Disk-1 |Disk |Disk-1 |Size_MB |7726 |
|Summary~>Disk~>Disk-1 |Disk |Disk-1 |Write_MB |694 |
|Summary~>Disk~>Disk-1 |Disk |Disk-1 |Time_Pct |4 |
|Summary~>Disk~>Disk-1 |Disk |Disk-1 |Disk |DISK0 |
|Summary~>Disk~>Disk-2 |Disk |Disk-2 |Size_MB |476937 |
|Summary~>Disk~>Disk-2 |Disk |Disk-2 |Write_MB |0 |
|Summary~>Disk~>Disk-2 |Disk |Disk-2 |Time_Pct |4 |
|Summary~>Disk~>Disk-2 |Disk |Disk-2 |Disk |DISK1 |
+------------------------+--------+--------+---------------+------------+
I can do a normal query to get attr_value of a attr_name. But I want to get all the output rows which has relation with same instance.
like I want to get all the attr_name and attr_value group by instance where attr_value='DISK1', while query reference will be attr_value only.
If I query like select relation, all attr_name as column, all attr_value as value from table name where attr_value IN (DISK1) for the related instance. for this query below should be output. I don't want to group by instance because query needs to be based upon attr_value.
Can I get this value?
+------------------------+--------+--------+----------+----------+---------+------+
|relation |object |instance|Size_MB |Write_MB |Time_Pct |DISK |
+------------------------+--------+--------+----------+----------+---------+------+
|Summary~>Disk~>Disk-2 |Disk |Disk-2 |476937 |0 |4 |DISK1 |
+------------------------+--------+--------+----------+----------+---------+------+