【发布时间】:2019-10-22 14:07:30
【问题描述】:
我正在尝试从 bigquery 查询数据并使用 Airflow 将其写入数据帧。但它要么给出file not found(服务帐户密钥)或file name is too long或eof line read错误。
我也尝试过使用钩子,但我无法将密钥文件作为 json 文件,因为它说它太长了。
关于如何实现它的任何提示?
def get_data_from_GBQ():
global customer_data
ofo_cred = Variable.get("ofo_cred")
logging.info(ofo_cred)
logging.info("Variable is here")
customer_data_query = """ SELECT FirstName, LastName, Organisation FROM `bigquery-bi.ofo.Customers` LIMIT 2 """
logging.info("test")
# Creating a connection to the google bigquery
client = bigquery.Client.from_service_account_json(ofo_cred)
logging.info("after client")
customer_data = client.query(customer_data_query).to_dataframe()
logging.info("after client")
print(customer_data)
dag = DAG(
'odoo_gbq_connection',
default_args=default_args,
description='A connection between ',
schedule_interval=timedelta(days=1),)
错误是:
FileNotFoundError: [Errno 2] No such file or directory: '{\r\n "type": "service_account",\r\n "project_id":...
【问题讨论】:
-
我很好奇您为什么会看到 3 种不同类型的错误消息。您能否为您的问题添加更多细节?
-
很高兴看到您的 DAG 代码。请准备最小的例子
-
@YunZhang 我没有看到他们三个在一起。每次,当我尝试新事物时,都会抛出不同的错误:(
-
@ArtemVovsia 我已经更新了。你能检查一下吗?这是一个完全正常的日志变量,但是在授权期间,它会抛出上面的错误。我不知道为什么。
-
您使用的是开源 Airflow 还是 Cloud Composer?
标签: sql pandas dataframe google-bigquery airflow