Autocomplete¶
sql-autocomplete provides schema-aware SQL completion once you build a metadata index with :TDSync.
Metadata sync (:TDSync)¶
Full catalog synchronization builds or refreshes the local index of databases → tables → columns from your active connection:
:TDSync
- Connects to Teradata using the active user connection via TPT.
- Indexes all schemas visible to the user (filtered by
filter_dbif configured). - Typical duration: ~2 minutes for systems with millions of columns.
- Requires read access to
dbc.columnsv. - Writes one metadata catalog per machine (
tdpid) underdata_dir(stdpath('data') .. '/teradata').
Incremental sync (:TDSync add / update / delete)¶
Instead of running a full catalog sync whenever a table or schema changes, you can incrementally add, refresh, or remove objects on demand in seconds:
:[range]TDSync[!] add [DB.OBJ ...]
:[range]TDSync[!] update [DB.OBJ ...]
:[range]TDSync delete [DB.OBJ ...]
Subcommands¶
| Action | Description |
|---|---|
add |
Fetches metadata for the given objects from DBC.ColumnsV via TPT and merges them into the local catalog. |
update |
Fetches the given objects via TPT, merges them into the local catalog, and removes any requested objects that no longer exist on the server. |
delete |
Removes the given objects from the local catalog directly. Synchronous and executes locally without querying the server. |
Target options¶
You can target objects in several flexible ways:
-
Explicit object names: Pass one or more qualified objects separated by spaces or commas:
Placeholders defined in:TDSync add PROD_DB.Orders PROD_DB.Customersreplacements(such as${DB_NAME}) are automatically expanded. -
Wildcard whole database (
DB.*): Update or delete an entire database::TDSync update PROD_DB.* :TDSync delete STAGING_DB.* -
From cursor position (no arguments): In a Teradata buffer,
:TDSync addor:TDSync updatewithout arguments inspects the Tree-sitterobject_referencenode under the cursor and syncs that table automatically. -
From visual selection: Highlight SQL statements containing table references and run:
Object names are extracted directly from the selected text.:'<,'>TDSync add
Volatile & Temporary tables¶
When working with session-level tables (CREATE VOLATILE TABLE or CREATE GLOBAL TEMPORARY TABLE), pass an unqualified single-part table name:
:TDSync add vt_orders
- Session-only registry: Registered in memory for the active Neovim session (not persisted to disk).
- Tree-sitter AST extraction (default): By default, column definitions are extracted directly from the
CREATE VOLATILE TABLEorCREATE GLOBAL TEMPORARY TABLEstatement found in the current buffer. - Server-side column resolution (
!): Append!to verify column definitions on Teradata:This runs a fast one-shot BTEQ job that creates the table with:TDSync add! vt_orders " or :TDSync! add vt_ordersWITH NO DATAand executesHELP COLUMN vt_orders.*on the server to accurately resolve types and computed column names. - Removing session tables: To remove a volatile table from autocomplete:
:TDSync delete vt_orders
Completion behavior¶
- Scope-aware suggestions:
- After
FROMorJOIN: completes databases, then tables. - After
<table>.: completes columns belonging to that table. - Teradata built-in SQL functions are always suggested.
- After
- Case-insensitive matching.
- Candidate ranking and fuzzy matching are handled by your completion plugin.
Supported engines¶
blink.cmp¶
Automatically registered as a completion provider if blink.cmp is detected.
nvim-cmp¶
Automatically registered if nvim-cmp is detected. Simply add td_sql_completion to your sources list:
cmp.setup({
sources = {
{ name = 'td_sql_completion' },
-- your other sources...
},
})
Built-in omnifunc (<C-X><C-U>)¶
If you do not use blink.cmp or nvim-cmp, you can invoke native Neovim completion anywhere in a Teradata buffer using insert-mode <C-X><C-U>.