LoginSignup
2
0

More than 5 years have passed since last update.

BigQueryに入れたDatastoreのテーブルをParent KeyでJOINする

Last updated at Posted at 2017-01-17

DatastoreのレコードをBigQueryに入れるのはこっち参照: http://qiita.com/tab02733/items/966eab11be6845eaf3ee

Datastore Backupから取り込んだtableにあるkey関連のカラム
image

この中の、__key__.pathにこんな感じでancestor keyが文字列で入っている。

"ParentEntity", "9512e2b44c614b23216...", "ChildEntity", "child_key_name"

SQL関数で__key__.pathをバラしてやればJOINできた。

SELECT
  parent.hogehoge
FROM
  [datastore_backup20170117.Parent] parent
LEFT JOIN (
  SELECT
    REPLACE(NTH(2, SPLIT(__key__.path, ', ')), '"', '') parent_key_name
  FROM
    [datastore_backup20170117.Child]) child
ON
  parent.__key__.name = child.parent_key_name
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0