我最近开始研究气流。我正在研究DAG:
Dag导入三个运算符:MySqlOperator
,MySqlToGoogleCloudStorageOperator
和{
我使用的是Airflow 1.8.0、Python3和Pandas 0.19.0。在
这是我的Dag代码:
sql2gcp_csv = MySqlToGoogleCloudStorageOperator(
task_id='sql2gcp_csv',
sql='airflow_gcp/aws_sql_extract_7days.sql',
bucket='gs://{{var.value.gcs_bucket}}/{{ ds_nodash }}/',
filename='{{ ds_nodash }}-account-*.json',
schema_filename='support/file.json',
approx_max_file_size_bytes=1900000000,
mysql_conn_id='aws_mysql',
google_cloud_storage_conn_id='airflow_gcp',
)
但是,当我运行它时,我收到以下错误:
^{pr2}$有人知道为什么抛出这个异常吗?在
根据您的回溯,您的代码在this point处中断。如您所见,它处理代码:
tmp_file_handle
是一个带有默认输入参数的NamedTemporaryFile
initialized,也就是说,它模拟用w+b
模式打开的文件(因此只接受类似字节的数据作为输入)。在问题是在Python2中所有的字符串都是字节,而在Python3中,字符串是文本(默认编码为
utf-8
)。在如果打开Python 2并运行以下代码:
^{pr2}$它工作得很好。在
但如果打开Python 3并运行相同的代码:
我们的错误和你的一样。在
这意味着python3仍然不完全支持flow(正如您在test coverage中看到的那样,
airflow/contrib/operators/mysql_to_gcs.py
模块尚未在python2或python3中进行测试)。确认这一点的一种方法是使用python2运行代码,看看它是否有效。在我建议在their JIRA上创建一个问题,请求两个版本的Python的可移植性。在
相关问题 更多 >
编程相关推荐