简体   繁体   English

如何使用 BigQuery SQL 查询从 Firestore 查询 noSQL 数据?

[英]How can I query noSQL data from Firestore with BigQuery SQL queries?

I exported hierarchically structured data with Firebase hash-keys to BigQuery.我使用 Firebase 哈希键将分层结构化数据导出到 BigQuery。 However, since the data is not structured in tables, I don't know how to use SQL queries to get desired information.但是,由于数据不是在表中结构化的,我不知道如何使用 SQL 查询来获取所需的信息。 Is this possible in principle or do I need to convert / flatten the data into tables first?原则上这是可能的还是我需要先将数据转换/展平成表格? Google seems to advice visualizing data in Data Studio using BigQuery as source (not Firebase/Firestore directly). Google 似乎建议在 Data Studio 中使用 BigQuery 作为源(而不是直接使用 Firebase/Firestore)来可视化数据。 Yet, I cannot find any useful information / sample queries for this case.但是,对于这种情况,我找不到任何有用的信息/示例查询。 Thank you very much in advance.非常感谢您提前。

I'm not familiar with the "hierarchically structured data with Firebase hash-keys", but the general guideline here to query such 'blob/text' data (from BigQuery perspective) is:我不熟悉“具有 Firebase 哈希键的分层结构化数据”,但此处查询此类“blob/text”数据的一般准则(从 BigQuery 的角度来看)是:

  1. As you said, use separate pipeline to load / save the data into BQ table structure, or如您所说,使用单独的管道将数据加载/保存到 BQ 表结构中,或者
  2. Define a function to access your data.定义一个 function 来访问您的数据。 Since the function body could be JavaScript, you have the full flexibility to parse / read your text/blob data:由于 function 主体可能是 JavaScript,因此您可以完全灵活地解析/读取文本/blob 数据:
CREATE FUNCTION yourDataset.getValue(input STRING, key STRING)
RETURNS STRING
LANGUAGE js
AS """
// JavaScript code to read the data
""";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM