将 Bigquery SQL 转换为物化视图

问题描述 投票:0回答:1

我有一个 bigquery sql 命令,它以某种格式从数据库获取数据。我希望它处于物化视图中,但我收到以下错误

Incremental materialized views may not use the ARRAY function.

这是 SELECT SQL 命令

SELECT
  '' as Status,
  Country,
  'US-Docketing' as Source,
  customer_name as CustomerName,
  customer_number as CustomerNumber,
  client_number as ClientName,
  ClientId,
  application_number as `ApplicationNo`,
  docket_queue_id as `DocketNo`,
  attorney_docket_number as `AttorneyDocketNo`,
  DateReceived as `ReceivedDate`,
  ARRAY_AGG(
    STRUCT(
      document_details_unnest.DocumentCode,
      document_details_unnest.Title,
      document_details_unnest.JobDocumentId,
      document_details_unnest.JobDocumentSourceId,
      ARRAY(SELECT AS STRUCT
               annotationaId,
               display_name,
               Value,
               source
             FROM UNNEST(document_details_unnest.annotations)) as annotations
          )
  ) as DocumentDetails
FROM `PROJECT.POC.sample_mat_view`, UNNEST(document_details) as document_details_unnest
GROUP BY 1,2,3,4,5,6,7,8,9,10,11;

我也尝试了物化视图的非增量版本,但它的最短陈旧时间可能是 30 分钟。而且我似乎无法手动刷新它。

如果无法创建增量materializd视图,我如何更改SQL命令以在不使用ARRAY函数的情况下提供相同的模式。

如有任何帮助,我们将不胜感激。预先感谢。

sql google-cloud-platform google-bigquery
1个回答
0
投票

正如 @guillaume blaquiere 评论的那样,增量物化视图有一些限制,而您达到了一个。

非增量版本更昂贵,但解决了这些限制。最新的替代方案是更改您的模型和公开的数据,以符合增量物化视图。

更多说明请参阅link1link2

将答案发布为社区 wiki,以造福于将来可能遇到此用例的社区。请随意编辑此答案以获取更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.