I have some data in Google BigTable over which I have built a BigQuery external table (as per Querying Cloud Bigtable data so that I can query the Bigtable table using conventional SQL (which I'm very familiar with).
When I issue a select * I get this:

Now I would like to know the syntax for querying specific values in this nested data. For example, to get a list of accountIds I can do this:
SELECT ARRAY(SELECT timestamp FROM UNNEST(attributes.column[OFFSET(0)].cell)) AS timestamp,
ARRAY(SELECT SAFE_CONVERT_BYTES_TO_STRING(value) FROM UNNEST(attributes.column[OFFSET(0)].cell)) AS values
FROM `table`
where SAFE_CONVERT_BYTES_TO_STRING(rowkey) = 'XXXX'
which is, well, kinda handy.
Similarly I can get car#le11mcr#policyStartDate by changing the OFFSET like so:
SELECT ARRAY(SELECT timestamp FROM UNNEST(attributes.column[OFFSET(6)].cell)) AS timestamp,
ARRAY(SELECT SAFE_CONVERT_BYTES_TO_STRING(value) FROM UNNEST(attributes.column[OFFSET(6)].cell)) AS values
FROM `table`
where SAFE_CONVERT_BYTES_TO_STRING(rowkey) = 'XXXX'
However both of these queries require me to know what value to pass to OFFSET() and that value appears to depend on the alphabetical order of the Bigtable columns hence if another column whose name starts with (say) 'b' appears in the future my queries would no longer return the same thing.
I need a better way of querying the table than using OFFSET(). Essentially I want to be able to say:
select the cell values and timestamp values for the cell whose name is
accountId
or
select the cell values and timestamp values for the cell whose name is
car#le11mcr#policyStartDate
Is there a way to do that? I'm not too familiar with BigQuery syntax for doing this.



