简体   繁体   English

使用 window function 将 Google Data Studio 连接到 BigQuery 的问题

[英]Issues connecting Google Data Studio to BigQuery with window function

I have a complex BigQuery view that pulls data from various connected Google Sheets along with calculated data from within BigQuery.我有一个复杂的 BigQuery 视图,它从各种连接的 Google 表格中提取数据以及 BigQuery 中的计算数据。 I'm trying to create a dashboard on top of the view in Data Studio.我正在尝试在 Data Studio 中的视图之上创建一个仪表板。

I'm having an issue getting my data to show in Data Studio and have isolated it to a particular part of the underlying view in BigQuery.我在让我的数据显示在 Data Studio 中并将其隔离到 BigQuery 基础视图的特定部分时遇到问题。

I had an earlier problem that was answered by this question .我有一个较早的问题, 这个问题得到了回答。

I am running effectively the query from that post, saved as a view and then connected to Data Studio.我正在有效地运行该帖子中的查询,保存为视图,然后连接到 Data Studio。

SELECT order_id, order_date,
  ARRAY_AGG(line_item) AS line_items
FROM (
  SELECT order_id, order_date,
      STRUCT(item_sku,
      item_quantity,
      item_subtotal,
      cost.product_cost) AS line_item
  FROM `order_data_table`, UNNEST(line_items) AS items
  JOIN `price_history_table` AS cost
  ON items.item_sku = cost.sku AND effective_date < order_date 
  QUALIFY 1 = ROW_NUMBER() OVER(PARTITION BY order_id, order_date, item_sku ORDER BY effective_date DESC)
)
GROUP BY order_id, order_date   

This query uses a window function and it is this that is causing my issue.此查询使用 window function ,正是这导致了我的问题。 Whenever I try to connect to the data I get this.每当我尝试连接到数据时,我都会得到这个。

数据集配置错误

With the details being随着细节

Data Studio cannot connect to your data set.数据洞察无法连接到您的数据集。

Failed to fetch data from the underlying data set无法从底层数据集中获取数据

Removing the below line from the query solves the issue but then I don't have the desired data.从查询中删除以下行可以解决问题,但是我没有所需的数据。

QUALIFY 1 = ROW_NUMBER() OVER(PARTITION BY order_id, order_date, item_sku ORDER BY effective_date DESC)

Is there a reason why this breaks Data Studio?这是否会破坏 Data Studio? Can I avoid it?我可以避免吗? Can I solve the original issue in a different way that doesn't use a window function?我能否以不使用 window function 的不同方式解决原始问题?

UPDATE更新

Looks like there is an issue in Data Studio where it does not support the QUALIFY function. Data Studio 中似乎存在不支持 QUALIFY function 的问题。

Any suggestions on how I can re-write this query without using QUALIFY?关于如何在不使用 QUALIFY 的情况下重写此查询的任何建议?

I have fixed this by removing the QUALIFY function and re-writing my query as this我已通过删除 QUALIFY function 并将我的查询重写为这样来解决此问题

SELECT order_id, order_date,
  ARRAY_AGG(line_item) AS line_items
FROM (
  SELECT order_id, order_date,
      STRUCT(item_sku,
      item_quantity,
      item_subtotal,
      cost.product_cost,
      ROW_NUMBER() OVER(PARTITION BY order_id, order_date, item_sku ORDER BY effective_date DESC) AS row_num) AS line_item
  FROM `order_data_table`, UNNEST(line_items) AS items
  JOIN `price_history_table` AS cost
  ON items.item_sku = cost.sku AND effective_date < order_date 
)
WHERE line_item.row_num = 1
GROUP BY order_id, order_date 

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

相关问题 Google Workspace、BigQuery 和 Looker/Data Studio - Google Workspace, BigQuery and Looker/Data Studio 在连接 Google BigQuery 时遇到问题 - Getting trouble in connecting with Google BigQuery 将数据 stream 连接到 Google Voice App 中的用户响应的问题 - Issues connecting data stream to users responses in Google Voice App Google BigQuery 中的嵌套函数 window - Nested window functions in Google BigQuery 使用 GoogleCloud CLI 将 DataGrip 连接到 Google Bigquery - Connecting DataGrip to Google Bigquery using GoogleCloud CLI 将数据上传到 BigQuery 的 Google Cloud Function 的服务帐户角色 - Service account role for a Google Cloud Function that uploads data to BigQuery 在 Google Data Studio(Looker Studio) 中的现有报告中添加 BigQuery 查询结果 - Adding BigQuery query result in an already existing report in Google Data Studio(Looker Studio) Google BigQuery - 为什么 window function order by cause memory error although used with partition by - Google BigQuery - why does window function order by cause memory error although used together with partition by BigQuery 和 Data Studio 使用(成本) - BigQuery and Data Studio usage (cost) Google Cloud 中的数据验证 - BigQuery - Data validation in Google Cloud - BigQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM