| :py:mod:`airflow.providers.snowflake.transfers.snowflake_to_slack` |
| ================================================================== |
| |
| .. py:module:: airflow.providers.snowflake.transfers.snowflake_to_slack |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.snowflake.transfers.snowflake_to_slack.SnowflakeToSlackOperator |
| |
| |
| |
| |
| .. py:class:: SnowflakeToSlackOperator(*, sql, slack_message, snowflake_conn_id = 'snowflake_default', slack_conn_id = 'slack_default', results_df_name = 'results_df', parameters = None, warehouse = None, database = None, schema = None, role = None, slack_token = None, **kwargs) |
| |
| Bases: :py:obj:`airflow.models.BaseOperator` |
| |
| Executes an SQL statement in Snowflake and sends the results to Slack. The results of the query are |
| rendered into the 'slack_message' parameter as a Pandas dataframe using a JINJA variable called '{{ |
| results_df }}'. The 'results_df' variable name can be changed by specifying a different |
| 'results_df_name' parameter. The Tabulate library is added to the JINJA environment as a filter to |
| allow the dataframe to be rendered nicely. For example, set 'slack_message' to {{ results_df | |
| tabulate(tablefmt="pretty", headers="keys") }} to send the results to Slack as an ascii rendered table. |
| |
| .. seealso:: |
| For more information on how to use this operator, take a look at the guide: |
| :ref:`howto/operator:SnowflakeToSlackOperator` |
| |
| :param sql: The SQL statement to execute on Snowflake (templated) |
| :param slack_message: The templated Slack message to send with the data returned from Snowflake. |
| You can use the default JINJA variable {{ results_df }} to access the pandas dataframe containing the |
| SQL results |
| :param snowflake_conn_id: Reference to |
| :ref:`Snowflake connection id<howto/connection:snowflake>` |
| :param slack_conn_id: The connection id for Slack |
| :param results_df_name: The name of the JINJA template's dataframe variable, default is 'results_df' |
| :param parameters: The parameters to pass to the SQL query |
| :param warehouse: The Snowflake virtual warehouse to use to run the SQL query |
| :param database: The Snowflake database to use for the SQL query |
| :param schema: The schema to run the SQL against in Snowflake |
| :param role: The role to use when connecting to Snowflake |
| :param slack_token: The token to use to authenticate to Slack. If this is not provided, the |
| 'webhook_token' attribute needs to be specified in the 'Extra' JSON field against the slack_conn_id |
| |
| .. py:attribute:: template_fields |
| :annotation: :Sequence[str] = ['sql', 'slack_message'] |
| |
| |
| |
| .. py:attribute:: template_ext |
| :annotation: :Sequence[str] = ['.sql', '.jinja', '.j2'] |
| |
| |
| |
| .. py:attribute:: template_fields_renderers |
| |
| |
| |
| |
| .. py:attribute:: times_rendered |
| :annotation: = 0 |
| |
| |
| |
| .. py:method:: render_template_fields(self, context, jinja_env=None) |
| |
| Template all attributes listed in template_fields. |
| |
| This mutates the attributes in-place and is irreversible. |
| |
| :param context: Dict with values to apply on content |
| :param jinja_env: Jinja environment |
| |
| |
| .. 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. |
| |
| |
| |