I want to tanspose rows and columns in a hive table, get all rows and create columns for them , while the columns will become the rows.
My data look like this
Name week1 week2 week3
John 5 6 3
Mary 4 2 5
Marc 7 8 9
Jane 1 2 8
and the final output should be like this
week John Mary Marc Jane
week1 5 4 7 1
week2 6 2 8 2
week3 3 5 9 8
I have tried using a code from an existing thread but the rows that will become columns are so many (not just one like the 'val' column in that query) that I need to find a dynamic way of turning them into columns (and not mentioning the values one by one in the query)
SELECT id
, bool
, val
FROM (
SELECT id
, MAP('yes', yes, 'no', no) AS tmp_column
FROM database.table ) x
LATERAL VIEW EXPLODE(tmp_column) exptbl AS bool, val
the new column val that this query creates will not be suffice fo rmy data cause i am going to have a lot of columns