airflow.providers.teradata.hooks.bteq¶
Classes¶
Hook for executing BTEQ (Basic Teradata Query) scripts. |
Module Contents¶
- class airflow.providers.teradata.hooks.bteq.BteqHook(teradata_conn_id, ssh_conn_id=None, *args, **kwargs)[source]¶
Bases:
airflow.providers.teradata.hooks.ttu.TtuHook
Hook for executing BTEQ (Basic Teradata Query) scripts.
This hook provides functionality to execute BTEQ scripts either locally or remotely via SSH. It extends the TtuHook and integrates with Airflow’s SSHHook for remote execution.
The BTEQ scripts are used to interact with Teradata databases, allowing users to perform operations such as querying, data manipulation, and administrative tasks.
Features: - Supports both local and remote execution of BTEQ scripts. - Handles connection details, script preparation, and execution. - Provides robust error handling and logging for debugging. - Allows configuration of session parameters like output width and encoding.
See also
- Parameters:
bteq_script – The BTEQ script to be executed. This can be a string containing the BTEQ commands.
remote_working_dir – Temporary directory location on the remote host (via SSH) where the BTEQ script will be transferred and executed. Defaults to /tmp if not specified. This is only applicable when ssh_conn_id is provided.
bteq_script_encoding – Character encoding for the BTEQ script file. Defaults to ASCII if not specified.
timeout – Timeout (in seconds) for executing the BTEQ command. Default is 600 seconds (10 minutes).
timeout_rc – Return code to use if the BTEQ execution fails due to a timeout. To allow DAG execution to continue after a timeout, include this value in bteq_quit_rc. If not specified, a timeout will raise an exception and stop the DAG.
bteq_session_encoding – Character encoding for the BTEQ session. Defaults to UTF-8 if not specified.
bteq_quit_rc – Accepts a single integer, list, or tuple of return codes. Specifies which BTEQ return codes should be treated as successful, allowing subsequent tasks to continue execution.
- execute_bteq_script(bteq_script, remote_working_dir, bteq_script_encoding, timeout, timeout_rc, bteq_session_encoding, bteq_quit_rc, temp_file_read_encoding)[source]¶
Execute the BTEQ script either in local machine or on remote host based on ssh_conn_id.
- execute_bteq_script_at_remote(bteq_script, remote_working_dir, bteq_script_encoding, timeout, timeout_rc, bteq_session_encoding, bteq_quit_rc, temp_file_read_encoding)[source]¶