blob: e1f8a3d62f7f934640785a5e5c1026c9a54f850f [file] [log] [blame]
.. py:module:: airflow.providers.apache.hive.transfers.hive_to_mysql
.. autoapi-nested-parse::
This module contains an operator to move data from Hive to MySQL.
Module Contents
.. autoapisummary::
.. autoapisummary::
.. py:data:: MYSQL_RENDERER
.. py:class:: HiveToMySqlOperator(*, sql, mysql_table, hiveserver2_conn_id = 'hiveserver2_default', mysql_conn_id = 'mysql_default', mysql_preoperator = None, mysql_postoperator = None, bulk_load = False, hive_conf = None, **kwargs)
Bases: :py:obj:`airflow.models.BaseOperator`
Moves data from Hive to MySQL, note that for now the data is loaded
into memory before being pushed to MySQL, so this operator should
be used for smallish amount of data.
:param sql: SQL query to execute against Hive server. (templated)
:param mysql_table: target MySQL table, use dot notation to target a
specific database. (templated)
:param mysql_conn_id: source mysql connection
:param metastore_conn_id: Reference to the
:ref:`metastore thrift service connection id <howto/connection:hive_metastore>`.
:param mysql_preoperator: sql statement to run against mysql prior to
import, typically use to truncate of delete in place
of the data coming in, allowing the task to be idempotent (running
the task twice won't double load data). (templated)
:param mysql_postoperator: sql statement to run against mysql after the
import, typically used to move data from staging to
production and issue cleanup commands. (templated)
:param bulk_load: flag to use bulk_load option. This loads mysql directly
from a tab-delimited text file using the LOAD DATA LOCAL INFILE command.
This option requires an extra connection parameter for the
destination MySQL connection: {'local_infile': true}.
:param hive_conf:
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['sql', 'mysql_table', 'mysql_preoperator', 'mysql_postoperator']
.. py:attribute:: template_ext
:annotation: :Sequence[str] = ['.sql']
.. py:attribute:: template_fields_renderers
.. py:attribute:: ui_color
:annotation: = #a0e08c
.. py:method:: execute(self, context)
This is the main method to derive when creating an operator.
Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.