【问题标题】:Cannot fix start manual transfer runs method for bigquery_datatransfer_v1无法修复 bigquery_datatransfer_v1 的启动手动传输运行方法
【发布时间】:2021-08-31 12:35:47
【问题描述】:

我试图仅在大查询中的表更新时运行计划查询。为此,我试图让这个 python 代码在云函数中工作,但它给了我错误。非常感谢任何帮助。

我正在运行这个 python 代码:

import time
from google.protobuf.timestamp_pb2 import Timestamp
from google.cloud import bigquery_datatransfer_v1

def runQuery (parent,requested_run_time):
    client = bigquery_datatransfer_v1.DataTransferServiceClient()
    projectid = '629586xxxx' # Enter your projectID here
    transferid = '60cc15f8-xxxx-xxxx-8ba2-xxxxx41bc'  # Enter your transferId here
    parent = client.transfer_config_path(projectid, transferid)
    start_time = Timestamp(seconds=int(time.time() + 10))
    response = client.start_manual_transfer_runs(parent, requested_run_time=start_time)
    print(response)

我收到此错误

start_manual_transfer_runs() got an unexpected keyword argument 'requested_run_time'

【问题讨论】:

  • 嗨@usman rafi,这解决了吗?我想知道您是如何触发云功能的,因为您只想在大查询中的表更新时才运行计划查询。你在使用 pub 子事件吗?

标签: google-cloud-platform google-bigquery google-cloud-functions


【解决方案1】:

我使用云功能创建了这个功能,它对我有用。

import time
from google.protobuf.timestamp_pb2 import Timestamp 
from google.cloud import bigquery_datatransfer_v1

def runQuery(parent, requested_run_time):
    client = bigquery_datatransfer_v1.DataTransferServiceClient()
    PROJECT_ID = 'graphical-reach-285218'
    TRANSFER_CONFIG_ID = '61adfc39-0000-206b-a7b0-089e08324288'
    parent = client.project_transfer_config_path(PROJECT_ID, TRANSFER_CONFIG_ID)
    start_time = bigquery_datatransfer_v1.types.Timestamp(seconds=int(time.time() + 10))
    response = client.start_manual_transfer_runs(parent, requested_run_time=start_time)
    print(parent)
    print(response)

替换为您的项目 ID 并传输配置 ID。以上代码会在 main.py 和 requirements.txt 中,请保留

google-cloud-bigquery-datatransfer==1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 2020-01-18
    • 1970-01-01
    相关资源
    最近更新 更多