Error: BigQuery does not support temporary tables

Error: BigQuery does not support temporary tables

我正在尝试连接同一项目中两个不同数据集的表。我该怎么做?

    library(tidyverse)
    library(bigrquery)
    
    con1 <- 
      bConnect(
        drv = bigrquery::bigquery(),
        project = PROJECT,
        dataset = "dataset_1"
      )
    con2 <- 
      bConnect(
        drv = bigrquery::bigquery(),
        project = PROJECT,
        dataset = "dataset_2"
      )
    
    A <- con1 %>% tbl("A")
    B <- con2 %>% tbl("B")
    
    inner_join(A, B,
              by = "key",
              copy = T) %>%
      collect()

然后我得到错误:Error: BigQuery does not support temporary tables

问题很可能是您使用不同的连接来连接两个 table。当您尝试这样做时,R 会尝试将数据从一个源复制到另一个源上的临时 table。

this question and the copy parameter in this documentation(封装不同,原理相同)

解决方案是对所有 table 只使用一个连接。像这样:

con <- 
  bConnect(
    drv = bigrquery::bigquery(),
    project = PROJECT,
    dataset = "dataset_1"
  )
    
A <- con %>% tbl("A")
B <- con %>% tbl("B")
    
inner_join(A, B,
           by = "key") %>%
  collect()

您可能需要在连接字符串中将 dataset 参数留空,或者在连接到远程 table。如果不了解更多有关数据库结构的信息,则很难确定。