我正在研究一个查询MySQL数据库的DAG,将数据提取并加载到Google Cloud 端存储 .
我要导出的表包括text,int,float,varchar(20)和varchar(32)数据 .
我使用的是airflow v1.8.0 .
default_args = {
'owner' : 'tia',
'start_date' : datetime(2018, 1, 4),
'depends_on_past' : False,
'retries' : 1,
'retry_delay':timedelta(minutes=5),
}
dag = DAG('mysql_to_gcs', default_args=default_args)
export_waybills = MySqlToGoogleCloudStorageOperator(
task_id='extract_waybills',
mysql_conn_id = 'podiotestmySQL',
sql = 'SELECT * FROM podiodb.logistics_waybills',
bucket='podio-reader-storage',
filename= 'podio-data/waybills{}.json',
schema_filename='podio-data/schema/waybills.json',
dag=dag)
我突然发现以下错误,这似乎与此类似Airflow mysql to gcp Dag error
[2018-01-04 11:12:23,372] INFO - 执行2018-01-04 00:00:00 [2018-01-04 11:12:23,400] {base_hook.py :67}信息 - 使用连接到:35.189.207.140 [2018-01-04 11:12:24,903] 错误 - 需要一个类似字节的对象,而不是'str'跟踪(最近一次调用) last):文件“/home/hyperli/.local/lib/python3.5/site-packages/airflow/models.py”,第1374行,在运行结果= task_copy.execute(context = context)文件“/ home / hyperli / .local / lib / python3.5 / site-packages / airflow / contrib / operators / mysql_to_gcs.py“,第91行,执行files_to_upload = self._write_local_data_files(cursor)文件”/home/hyperli/.local/lib /python3.5/site-packages/airflow/contrib/operators/mysql_to_gcs.py“,第136行,在_write_local_data_files中json.dump(row_dict,tmp_file_handle)文件”/usr/lib/python3.5/json/init.py“ ,第179行,在转储fp.write(块)文件“/usr/lib/python3.5/tempfile.py”,第622行,在func_wrapper中返回func(* args,** kwargs)TypeError:类似字节的对象是必需的,不是'str'[2018-01-04 11:12:24,907] 信息 - 将任务标记为UP_FOR_RETRY [2018-01-04 11:12:25,037] 错误 - a类似字节的对象是必需的,而不是'str'
有谁知道抛出异常的原因?
1 回答
你在使用python 3吗?因为它接缝mysql_to_gcs的最新版本(1.90)不兼容python接缝 .
它接缝此操作符已更改here以使mysql_to_gcs py3兼容 . 但latest version(1.90)不包括this change