Jeado Ko
Jeado Ko

Reputation: 21

Querying Bigtable to scan rowkey from Bigquery

Using BigQuery's Bigtable external data source, I'd like to scan rowkeys in Bigtable.

Here is BigTable schema which is similar to the official document`s time series one.

EXCHANGE + SYMBOL + DATE (for example, NASDAQ#ZXZZT#2020-02-01

I`d like to know how to query all data between 2020-01-01 to 2020-02-01.

I tried this way but it does not work... SELECT rowkey from blah.blah where rowkey >= "2020-01-01" AND rowkey <= "2020-02-01"

Upvotes: 1

Views: 331

Answers (1)

Jeado Ko
Jeado Ko

Reputation: 21

I found out the query by myself... but not sure is it a good or a bad query.

SELECT * FROM 
(SELECT
  (SELECT keys FROM UNNEST(SPLIT(rowkey, "|")) as keys WITH OFFSET AS offset WHERE offset = 0) as exchange,
  (SELECT keys FROM UNNEST(SPLIT(rowkey, "|")) as keys WITH OFFSET AS offset WHERE offset = 1) as symbol,
  (SELECT keys FROM UNNEST(SPLIT(rowkey, "|")) as keys WITH OFFSET AS offset WHERE offset = 2) as biz_date,
FROM
  `blah.blah`)
WHERE biz_date < '2020-01-01' AND ccy = 'SGD'

Upvotes: 1

Related Questions