当前位置: 首页>>代码示例>>Python>>正文


Python bigquery_operator.BigQueryOperator方法代码示例

本文整理汇总了Python中airflow.contrib.operators.bigquery_operator.BigQueryOperator方法的典型用法代码示例。如果您正苦于以下问题:Python bigquery_operator.BigQueryOperator方法的具体用法?Python bigquery_operator.BigQueryOperator怎么用?Python bigquery_operator.BigQueryOperator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.contrib.operators.bigquery_operator的用法示例。


在下文中一共展示了bigquery_operator.BigQueryOperator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_operator_param_name_and_values

# 需要导入模块: from airflow.contrib.operators import bigquery_operator [as 别名]
# 或者: from airflow.contrib.operators.bigquery_operator import BigQueryOperator [as 别名]
def _get_operator_param_name_and_values(operator_class_name, task_details):
    """ Internal helper gets the name of the python parameter for the Airflow operator class. In
      some cases, we do not expose the airflow parameter name in its native form, but choose to
      expose a name that's more standard for Datalab, or one that's more friendly. For example,
      Airflow's BigQueryOperator uses 'bql' for the query string, but we want %%bq users in Datalab
      to use 'query'. Hence, a few substitutions that are specific to the Airflow operator need to
      be made.

      Similarly, we the parameter value could come from the notebook's context. All that happens
      here.

      Returns:
        Dict containing _only_ the keys and values that are required in Airflow operator definition.
      This requires a substituting existing keys in the dictionary with their Airflow equivalents (
      i.e. by adding new keys, and removing the existing ones).
    """

    # We make a clone and then remove 'type' and 'up_stream' since these aren't needed for the
    # the operator's parameters.
    operator_task_details = task_details.copy()
    if 'type' in operator_task_details.keys():
      del operator_task_details['type']
    if 'up_stream' in operator_task_details.keys():
      del operator_task_details['up_stream']

    # We special-case certain operators if we do some translation of the parameter names. This is
    # usually the case when we use syntactic sugar to expose the functionality.
    # TODO(rajivpb): It should be possible to make this a lookup from the modules mapping via
    # getattr() or equivalent. Avoid hard-coding these class-names here.
    if (operator_class_name == 'BigQueryOperator'):
      return PipelineGenerator._get_bq_execute_params(operator_task_details)
    if (operator_class_name == 'BigQueryToCloudStorageOperator'):
      return PipelineGenerator._get_bq_extract_params(operator_task_details)
    if (operator_class_name == 'GoogleCloudStorageToBigQueryOperator'):
      return PipelineGenerator._get_bq_load_params(operator_task_details)
    return operator_task_details 
开发者ID:googledatalab,项目名称:pydatalab,代码行数:38,代码来源:_pipeline.py


注:本文中的airflow.contrib.operators.bigquery_operator.BigQueryOperator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。