有没有办法在一个 select 语句中取消嵌套数组?

Is there a way to unnest an array in one select statement?

我有以下内容:

CTE AS (
  SELECT 
    IssueID, CompanyName, Customer.ID FROM
 ( SELECT
    IssueID,
    REGEXP_EXTRACT_ALL(CompanyName,'[a-zA-Z]{3,4}[0-9]{3,4}') AS CompanyName
  FROM 
    `DWH.website` Website
  LEFT JOIN  `DWH.issues` AS Issue ON DWH.IssueID = Issue.ID) AS BASE

CROSS JOIN UNNEST (CompanyName) AS CompanyName
LEFT JOIN 
  DWH.Customer ON  CompanyName = Customer.CompanyName
)

我想知道是否有更有效的写法,特别是是否有一种方法可以在一个 Select 语句中进行 UNNEST。

期望输出示例

IssueID CompanyName ID
18677 Google 19435
18677 Logitech 22345
34564 Target 76845

它看起来像是更大查询的一部分(因为 DWHCustomer 等表丢失了),但是,假设它有效,您可以试试这个:

CTE AS (
  SELECT IssueID, CompanyName, Customer.ID 
  FROM `DWH.website` Website
  LEFT JOIN `DWH.issues` AS Issue ON DWH.IssueID = Issue.ID
  CROSS JOIN UNNEST(REGEXP_EXTRACT_ALL(CompanyName,'[a-zA-Z]{3,4}[0-9]{3,4}')) AS CompanyName
  LEFT JOIN DWH.Customer ON CompanyName = Customer.CompanyName
)