You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bteq_operator method enables execution of SQL statements or BTEQ (Basic Teradata Query) scripts using the Teradata BTEQ utility.
128
+
It supports running commands either on the local machine or on a remote machine over SSH — in both cases, the BTEQ utility must be installed on the target system.
129
+
130
+
### Key Features
131
+
132
+
- Executes SQL provided as a string or from a script file (only one can be used at a time).
133
+
- Supports custom encoding for the script or session.
134
+
- Configurable timeout and return code handling.
135
+
- Remote execution supports authentication using a password or an SSH key.
136
+
- Works in both local and remote setups, provided the BTEQ tool is installed on the system where execution takes place.
137
+
138
+
> Ensure that the Teradata BTEQ utility is installed on the machine where the SQL statements or scripts will be executed.
139
+
>
140
+
> This could be:
141
+
> * The local machine where Dagster runs the task, for local execution.
142
+
> * The remote host accessed via SSH, for remote execution.
143
+
> * If executing remotely, also ensure that an SSH server (e.g., sshd) is running and accessible on the remote machine.
144
+
145
+
### Parameters
146
+
147
+
-`sql`: SQL statement(s) to be executed using BTEQ. (optional, mutually exclusive with `file_path`)
148
+
-`file_path`: If provided, this file will be used instead of the `sql` content. This path represents remote file path when executing remotely via SSH, or local file path when executing locally. (optional, mutually exclusive with `sql`)
149
+
-`remote_host`: Hostname or IP address for remote execution. If not provided, execution is assumed to be local. *(optional)*
150
+
-`remote_user`: Username used for SSH authentication on the remote host. Required if `remote_host` is specified.
151
+
-`remote_password`: Password for SSH authentication. Optional, and used as an alternative to `ssh_key_path`.
152
+
-`ssh_key_path`: Path to the SSH private key used for authentication. Optional, and used as an alternative to `remote_password`.
153
+
-`remote_port`: SSH port number for the remote host. Defaults to `22` if not specified. *(optional)*
154
+
-`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.
155
+
-`bteq_script_encoding`: Character encoding for the BTEQ script file. Defaults to ASCII if not specified.
156
+
-`bteq_session_encoding`: Character set encoding for the BTEQ session. Defaults to ASCII if not specified.
157
+
-`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.
158
+
-`timeout`: Timeout (in seconds) for executing the BTEQ command. Default is 600 seconds (10 minutes).
159
+
-`timeout_rc`: Return code to use if the BTEQ execution fails due to a timeout. To allow Ops 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 Ops.
160
+
161
+
### Returns
162
+
163
+
- Output of the BTEQ execution, or `None` if no output was produced.
164
+
165
+
### Raises
166
+
167
+
-`ValueError`: For invalid input or configuration
168
+
-`DagsterError`: If BTEQ execution fails or times out
169
+
170
+
### Notes
171
+
172
+
- Either `sql` or `file_path` must be provided, but not both.
173
+
- For remote execution, provide either `remote_password` or `ssh_key_path` (not both).
174
+
- Encoding and timeout handling are customizable.
175
+
- Validates remote port and authentication parameters.
176
+
177
+
### Example Usage
178
+
179
+
```python
180
+
# Local execution with direct SQL
181
+
output = bteq_operator(sql="SELECT * FROM table;")
0 commit comments