tdfs4ds.server_side_batch¶
tdfs4ds.server_side_batch
¶
Server-side batch: the statements of one ingestion batch in ONE round trip (0.3.8.0, opt-in).
A batch stores its staged features with one MERGE per feature (feature_merge_statements). On a
remote client each statement is a round trip. With tdfs4ds.SERVER_SIDE_BATCH set, the MERGEs go to
the database as ONE CALL of a generic stored procedure that runs them with dynamic SQL, in order.
SERVER_SIDE_BATCH (env TDFS4DS_SERVER_SIDE_BATCH): 'off' (default, today's statements),
'auto' / 'procedure' (the procedure; installed once by :func:install_server_side_batch, never
created implicitly), 'macro' (accepted; see below).
Why a generic procedure and no per-process macro (measured on Vantage 20): the statements of a batch
name the staging volatile table, whose name changes at every batch, and carry the valid time as a
VALIDTIME PERIOD '(...)' literal. A macro takes parameters for values, never for identifiers or a
temporal qualifier, so one macro per process would need its text rebuilt (and re-installed) at every
batch: no gain. Dynamic SQL inside a procedure takes both. 'macro' therefore behaves as 'auto'
with one warning that says so.
Contract (each point has a test):
- Outcome identical. The same statements, in the same order, in the same session (the staging
table is volatile and visible). A data error surfaces as the same exception class
(
teradatasql.OperationalError) with the database's own message, sofailure_status/describe_db_error/ the FAILED follow-up text read as on the client path. - A refusal is not a failure. Missing procedure, no right to execute it, a statement the procedure cannot run: ONE warning, the mechanism is off for the session, and the SAME batch continues on the client path (the follow-up row is the one already RUNNING; no duplicate). The statements are idempotent MERGEs, so rerunning them after a partial run stores the same rows.
- Visible. The procedure text is in
FS_SERVER_BATCH_OBJECTS(optional table,FS_V_view), reviewed in the app (Performance > Server-side batches), checked by theserver_batchsanity check. - The procedure returns a result set
(failed_index, sqlstate, sqlcode, message):failed_index0 = everything ran; otherwise the 1-based index of the statement that failed.
_STATE
module-attribute
¶
sql_literal
¶
Escape value for use inside a single-quoted SQL string literal.
For the DBC probes and catalog predicates that compare a name as data
(WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.
procedure_ddl
¶
build_call
¶
CALL <proc>('<stmt1>/*;;*/<stmt2>') or None when the text is too long for one call.
classify_call_error
¶
'refused' (the mechanism is not usable: fall back) or 'data' (the statements' own error).
Matched on phrases, never on numbers. A missing object is a refusal only when it is OUR procedure
(or DBC.SysExecSQL): a missing table or column of a MERGE is the same error on the client path.
parse_result
¶
From the result sets of a CALL: (failed_index, sqlstate, sqlcode, message); None when none.
data_error
¶
The exception a client-path statement failure would raise (same class, same shape of message).
try_run
¶
Run statements in one CALL. True = they ran server-side; False = the client path must run
them (mechanism off, refused or not applicable). A data error raises as on the client path.
registry_creation
¶
Create the optional registry table and view when missing. Never raises.
registry_rows_sql
¶
The statements that make text the registered body of name now (close the old rows, insert the new).
install_script
¶
The statements :func:install_server_side_batch runs (pure; nothing executed).
install_server_side_batch
¶
Install (or replace) the generic batch procedure and record its text in the registry.
dry_run=True (default) only returns the statements. Nothing else changes: the mechanism stays
off until tdfs4ds.SERVER_SIDE_BATCH is set. Returns {'statements', 'applied', 'error'}.
drop_server_side_batch
¶
installed_objects
¶
Server-side objects of the store from DBC (procedures TDFS4DS_RUN_BATCH_*, macros TDFS4DS_B_*).
registered_objects
¶
{name: {version, hash, text, process_id}} from the registry (current valid time); {} when absent.
rights_verdict
¶
{'verdict': 'probable'|'unlikely'|'unknown', 'detail'} from the dictionary (never executes).
findings
¶
Pure: sanity findings from what is installed (installed_objects) and registered (registered_objects).
check_row
¶
The check_configuration row server_side_batch (never raises).
_probe
¶
Create, call and drop a throwaway copy of the procedure (opt-in: the only part that writes).
process_objects
¶
Objects registered for one process (none are created by the generic procedure; kept for removal).
drop_process_objects_sql
¶
Statements that drop the objects registered for process_id (per-process macros, if any).
review_model
¶
What the app tab shows (read-only): objects, their text, rights, drift, and the client SQL replaced.