Reputation: 59
I have data as in this BigQuery table
+-------+---------+------+------+
| chrom | start | stop | cons |
+-------+---------+------+------+
| chr1 | 1 | 5 | 0.3 |
| chr1 | 5 | 7 | 0.7 |
| chr2 | 1 | 3 | 0.2 |
+-------+---------+------+------+
where the value in "cons" is true for every number from start to stop (though the number in stop itself is excluded). Now I'd like to have the data in an non aggregated way, so the table would look like this
+-------+---------+------+------+
| chrom | start | stop | cons |
+-------+---------+------+------+
| chr1 | 1 | 2 | 0.3 |
| chr1 | 2 | 3 | 0.3 |
| chr1 | 3 | 4 | 0.3 |
| chr1 | 4 | 5 | 0.3 |
| chr1 | 5 | 6 | 0.7 |
| chr1 | 6 | 7 | 0.7 |
| chr2 | 1 | 2 | 0.2 |
| chr2 | 2 | 3 | 0.2 |
+-------+---------+------+------+
The
INSERT INTO
command is not supported by BigQuery. Any suggestions for a workaround?
Upvotes: 0
Views: 7485
Reputation: 3172
It should look something like:
Select chrome, Numbers.Number as Start, Numbers.Number+1 as stop, cons
from yourtable
cross join Numbers
where Numbers.Number>=Start and Number.Number<stop
Hope this helps
Upvotes: 2