Cloud Spanner 支持 GQL,并且可以将 Spanner 设置为 BigQuery 的外部数据集,如此处所示。鉴于此,是否可以在 BigQuery 中执行 GQL 查询,即使写入为要在 Spanner 执行的字符串?如果是的话,这怎么办?
您可以设置从 Cloud Spanner 到 BigQuery 的外部连接,并使用该连接 ID 运行它,例如以下 Cloud Spanner 数据库具有连接 ID
US.1234
:
SELECT * FROM EXTERNAL_QUERY("myproject.US.1234", """
GRAPH FinGraph
MATCH
(from_person:Person {name: "Dana"})-[:Owns]->
(from_account:Account)-[transfer:Transfers]->
(to_account:Account)<-[:Owns]-(to_person:Person)
RETURN
from_person.name AS from_account_owner,
from_account.id AS from_account_id,
to_person.name AS to_account_owner,
to_account.id AS to_account_id,
transfer.amount AS amount
""");