我目前正在为Airflow开发DAG.我喜欢使用PyCharm并倾向于为我的每个项目启动虚拟环境.
气流取决于安装期间设置的AIRFLOW_HOME文件夹.然后由Airflow在此文件夹中创建子目录.
我感兴趣的是其他人如何构建他们的项目以允许包含facebookads获取数据所需的包(例如)的虚拟环境- 同时还可以轻松地将DAG丢弃到Airflow的DAGS文件夹中进行测试.
我正在使用google-cloud-python库将数据加载到Google的BigQuery中,如下所示:
http://google-cloud-python.readthedocs.io/en/latest/index.html
其中一部分涉及检查要导入的数据的数据类型,以确保它们与目标表的架构中的数据类型匹配。为此,我将python对象类型转换为等效的GBQ:
import datetime
def convert_type_to_bigquery(object_type):
if isinstance(object_type, str):
return 'STRING'
elif isinstance(object_type, bytes):
return 'BYTES'
elif isinstance(object_type, int):
return 'INTEGER'
elif isinstance(object_type, float):
return 'FLOAT'
elif isinstance(object_type, bool):
return 'BOOLEAN'
elif isinstance(object_type, datetime.date):
return 'DATE'
elif isinstance(object_type, datetime.time):
return 'TIME'
elif isinstance(object_type, datetime.datetime):
return 'DATETIME'
elif isinstance(object_type, ???):
return 'TIMESTAMP'
else:
return None
Run Code Online (Sandbox Code Playgroud)
除了TIMESTAMP类型,我都能找到所有等效项。我可以用等效的东西isinstance()吗?