I have a problem in transposing a large amount of data table in BigQuery (1.5 billion rows) from rows to columns. I could figure out how to do it with small amount of data w
STEP #1
In below query replace yourTable
with real name of your table and execute/run it
SELECT 'SELECT CustomerID, ' +
GROUP_CONCAT_UNQUOTED(
'MAX(IF(Feature = "' + STRING(Feature) + '", Value, NULL))'
)
+ ' FROM yourTable GROUP BY CustomerID'
FROM (SELECT Feature FROM yourTable GROUP BY Feature)
As a result you will get some string to be used in next step!
STEP #2
Take string you got from Step 1 and just execute it as a query
The output is a Pivot you asked in question
Hi @Jade I posted a very similar question before. And got a very helpful (and similar) answer from @MikhailBerlyant. For what it's worth, I had about 4000 features to dummify in my case and also ran into "Resources exceeded during query execution" error.
I think that this type of large-scale data transformation (rather than query) is better left for other tools more suitable for this task (such as Spark).