Mapping File and Working Modes
TBT's two working modes, and the full structure of the mapping file that drives every job.
Two Working Modes: in_place and copy
The mapping file selects one of two working modes through the strategy section:
| Item | in_place | copy |
|---|---|---|
| What it does | Changes columns directly in the existing table | Reads the source table then writes all rows to the destination table |
| Source table | Changed | Never changed |
| Key column (primary key) | Cannot be changed | Can be changed |
| Destination table | None | Created from the source table, with the size of changed columns enlarged to fit their tokens |
| After completion | Original values are no longer stored in that table | Original values remain intact in the source table |
Copy mode carries every row, not just the protected columns, and adjusts column types automatically if the destination is a different database type. For copy, write the destination on the table in the mapping file:
destination:
connection: warehouse
table: nasabah_protected
create: true
Why can't in_place change the key column? TBT reads tables in row groups (windows), and each group asks for the rows after the last key the previous group saw. Change the key mid-run and the next group loses its position. Copy mode sidesteps this entirely since it reads from a source table that never changes.
Mapping File
One job = one mapping file (YAML or JSON). All commands use the same file. Complete example:
version: 1
job: protect-nasabah
# protect | unprotect
operation: protect
# in_place | copy
strategy: in_place
# tokenization | encryption | masking
method: tokenization
connection: core
tables:
- name: nasabah
# for PostgreSQL and Oracle
schema: public
# optional; found automatically if left empty
key: [id]
where: "created_at > '2020-01-01'"
columns:
- name: nik
function: fn-nik
# internal | generated | supplied (tokenization only)
tweak_type: internal
# fixed hex value, for tweak_type: supplied
tweak: ""
| Section | Meaning |
|---|---|
operation | protect protects data; unprotect restores it |
strategy | in_place or copy (see Two Working Modes above) |
method | Protection method: tokenization, encryption, or masking. Applies per column, so it can be changed for each column |
connection | Connection profile name (see Access Data, Connections, and Gateway Address) |
tables[].name, schema | Table to be processed; schema is used in PostgreSQL and Oracle |
tables[].key | Key column. Optional, found automatically if left empty |
tables[].where | Limits the rows to be processed |
columns[].name, function | Protected column and the protection function used |
columns[].tweak_type, tweak | Additional tokenization setting: internal, generated, or supplied (tweak is filled with a fixed hex value for supplied). See the warning about generated in Three Things That Can Cause Data Loss |
Fingerprint
TBT calculates a fingerprint from the mapping file's contents (comments, writing order, and function_name aren't part of the calculation). This fingerprint ties a run to the approved mapping file, which is why resume refuses to continue if the mapping file has changed.
Editing in a Spreadsheet
Jobs with dozens of columns are easier to review in a spreadsheet than in a text editor:
# save the mapping as a review sheet (CSV)
./run.sh export --mapping m.yaml
# apply the edited review sheet
./run.sh import --mapping m.yaml --sheet s.csv
The review sheet converts back and forth without losing content. import saves its result to a new file unless you pass --in-place, since the old mapping file may already be approved.
For how TBT connects to the platform and database, see Access Data, Connections, and Gateway Address. For how to read run results, see Run Results and Data Safety.