Full Exports (TPT)¶
When executing queries with :TDO or :TDV, BTEQ fetches a limited result set (capped by retlimit, default 100 rows) to keep Neovim fast and responsive.
For large or multi-million-row queries, vim-teradata provides background full-result exports powered by Teradata Parallel Transporter (TPT / tbuild). The data streams directly into a delimited CSV file on disk without loading large amounts of data into Neovim memory.
Quick Workflow¶
- Run query: Execute your query as usual with
:TDOor:TDV. If the result set exceedsretlimit, a warning indicates that results are truncated and mentionsF. - Trigger export:
- Press
Finside the result grid buffer. - Or run
:TDExportfrom any buffer to export the latest output query. - To export an older query from history, pass its ID:
:TDExport <id>(supports completion from query history).
- Press
- Confirm: A confirmation dialog displays the query ID, user, row count (if known), estimated file size, destination file path, and selected TPT operator route. Press
yto start (n,q, or<Esc>cancels). - Monitor: The export runs asynchronously in the background. Track progress in the Job Manager (
:TDJ), where the job is marked with operationexportand statusTPT running. - Inspect: Once complete, press
<CR>on the job in:TDJto open the first rows in a read-only preview grid.
Triggering an Export¶
Keymap in Result Buffers (F)¶
Inside any result grid produced by :TDO or :TDV, pressing F starts a full export for that query.
- The
Fkey is local to result buffers (it shadows Vim'sF{char}motion inside result buffers only). - You can change the keymap via
export.keymap(for example to"gF"), or set it tofalseto disable the key. Fis disabled onEXPLAINandSHOWgrids, on grids showing export previews, and while the result buffer is in Edit Mode.
Command: :TDExport¶
Available globally across any buffer:
:TDExport " Export latest query result
:TDExport 42 " Export history entry 42
Confirmation Dialog¶
Before starting the export, a confirmation window displays key job metadata:
Export full result with TPT?
Query: 42
User: USER @ HOST
Rows: ~1,250,000
Size: ~140 MB
File: ~/.local/share/nvim/teradata/history/exports/42.csv
Operator: EXPORT (FastExport protocol, 4 sessions)
[y] Export with TPT [n] Cancel
- Press
yto begin. - Press
n,q, or<Esc>to cancel. <CR>does nothing, preventing accidental confirmation.- To bypass confirmation and start exports immediately, set
export.confirm = false.
TPT Operator Routing: EXPORT vs. SELECTOR¶
TPT exports use one of two routes depending on the query structure and configuration:
┌─────────────────────────────┐
│ Eligible for wrapper? │
└──────────────┬──────────────┘
│
┌──────────────┴──────────────┐
YES NO
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Route W: EXPORT │ │ Route R: SELECTOR│
│ (FastExport) │ │ (Report Mode) │
│ Multi-session │ │ Single session │
└────────┬─────────┘ └──────────────────┘
│
Fails on data type?
(LOB, JSON, UDT, etc.)
│
▼ (Automatic Retry)
┌──────────────────┐
│ Route R: SELECTOR│
│ (Report Mode) │
└──────────────────┘
Route W: EXPORT Operator (Default)¶
The query is automatically wrapped so that every column is converted to text:
SELECT TRIM(t.c1) AS c1, ..., TRIM(t.cN) AS cN
FROM (<query>) AS t (c1, ..., cN);
- Formatting fidelity:
TRIMformats numbers and dates according to each column's TeradataFORMATdefinition, matching BTEQ output. - High throughput: Uses Teradata's multi-session FastExport protocol (governed by
export.max_sessions, default4). - Modifier preservation: A leading
LOCKING ... FOR ACCESSclause is automatically hoisted outside the wrapper.
Route R: SELECTOR Operator (Report Mode)¶
Submits the query unchanged using a single utility session in report mode. Route R is automatically chosen when:
- The query contains a top-level
ORDER BY(includingTOP n ... ORDER BYand set operations ending withORDER BY). - The query uses
WITH(Common Table Expressions / CTEs). - The query uses an unrecognized
LOCKINGclause. - Result preview headers are unavailable or the Tree-sitter parser is not loaded.
export.operatoris set to"selector"in your configuration.
Automatic Fallback & Retry¶
The high-performance EXPORT operator does not support certain complex Teradata data types (such as CLOB, BLOB, JSON, XML, PERIOD, BYTE, VARBYTE, or UDT).
If Route W fails with error codes TPT12108, TPT02639, or a TRIM failure on these types, vim-teradata automatically retries the export once using Route R (SELECTOR) within the same :TDJ job and notifies you.
To force SELECTOR mode from the start (useful on systems without FastExport utility session privileges), set:
export = {
operator = "selector",
}
Persistent Sessions (:TDSession)¶
Because TPT initiates its own independent database sessions via tbuild, it cannot access objects stored exclusively in a buffer's persistent BTEQ session (such as volatile tables, session-level query bands, or default databases set via DATABASE <name>;).
When an export is triggered for a query that ran in a persistent session:
- Warning: The confirmation dialog flags that the query ran inside a persistent session.
- Volatile table detection: If the query references volatile or temporary tables, TPT export is blocked. The dialog instead offers:
[b] Export with BTEQ inside the session - Selecting
[b]streams the full result through the buffer's existing BTEQ session with no row limits directly into the export file. While slower than TPT, this allows exporting volatile tables without data loss.
Managing Exports in Job Manager (:TDJ)¶
Full exports integrate directly into the Job Manager:
- Status indicator: Displays
TPT runningduring export, and reports the total exported row count when finished. - Previewing output (
<CR>): Press<CR>on a finished export job to open the first rows (export.head_lines, defaults toretlimit) in a read-only grid. A hint line displays total rows and destination path. - Canceling (
x): Pressingxterminates the export. Whentwbkillandtwbrmcputilities are available on$PATH, the job is terminated on Teradata, checkpoint files are purged, and the partial export file is cleaned up. - Deleting export files (
d): Pressingdon a completed export job prompts to delete the exported.csvfile from disk. The source query (queries/<id>.sql) is preserved.
Output Format & Storage¶
- Location: Files are stored under
<history_dir>/exports/<id>.csv(the subfolder name is configurable viaexports_dir_name). - Delimiter: Uses the configured field separator
sep(default"~"). Newlines and single quotes are not permitted insepfor exports. - NULL values: Written as empty fields (differing from the preview token
null_token). - Disk retention: Export files are managed and pruned alongside query history based on
history_max.
Troubleshooting TPT Exports¶
- View full TPT log: If an export fails, the job details in
:TDJdisplay relevant error lines. If the TPT job ID is known, run the following in your terminal to view the full TPT execution log:tlogview -j <jobid> -f '*' -g - Verify TTU utilities: Run
:checkhealth vim-teradatato verify thattbuild,twbkill,twbrmcp, andtlogvieware detected on your$PATH.