Skip to main content

Atlas Scripts

mask

A reusable, named mask. Define columns (globs allowed) and a method once at the top level, then apply it via use = [mask.<name>] from any query or script.

mask "pii" {
columns = ["ssn", "*email*"]
method = HASH
}

mask attributes

Name and descriptionRequiredValue

char

PARTIAL: replacement character (default *).

falsestring

columns

Output columns to mask, matched case-sensitively; an entry with */?/[...] is a glob (schema include/exclude style).

false

List of strings

keep

PARTIAL: characters kept at each end (default 0).

falseint

keep_left

PARTIAL: characters kept at the start (overrides keep).

falseint

keep_right

PARTIAL: characters kept at the end (overrides keep).

falseint

match

REPLACE: regular expression matched against the value.

falsestring

method

Masking method (REDACT default).

false

enum (REDACT, PARTIAL, HASH, REPLACE)

salt

HASH: secret salt. With it the digest is a keyed HMAC-SHA256; without it a bare (unsalted) SHA256 digest, which is susceptible to dictionary attacks for low-entropy values. Stable salts yield comparable tokens; recommended for sensitive data.

falsestring

token

REDACT: replacement token (default ***).

falsestring

with

REPLACE: replacement for the matched substring.

falsestring

mask constraints

ConstraintValue
Requiredfalse
Require Name (e.g., mask "name" )true
Repeatabletrue

script exec

Runs a sequence of condition, assert, check, exec, and query blocks as a program against the connected database. Blocks execute in their textual order; a failing assert/check/exec aborts the script (and rolls back when on_error = ROLLBACK), while an unmet condition stops it gracefully. A query binds its result for later steps as query.<name>.rows[*].<col>.

script.exec attributes

Name and descriptionRequiredValue

description

Free-form description; surfaced in audit logs.

falsestring

script.exec blocks

script.assert

An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).

assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.

script.assert attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

error_message

Message returned to the user when the assertion fails.

falsestring

sql

SQL query whose single boolean (or 1/0) result is asserted.

truestring
script.assert constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.check

A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.

check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.check attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

error_message

Message returned to the user when the check fails.

falsestring

format

Serialization format for the query output (CSV default, TABLE).

false

enum (CSV, TABLE)

match

Regular expression the output must match.

falsestring

output

Expected output, compared after trimming surrounding whitespace.

falsestring

sql

SQL query whose output is compared.

truestring
script.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

script.condition

A guard evaluated in textual order with the other steps. When its boolean SQL is not satisfied, the script stops gracefully at that point - committing the work done so far - without reporting a failure.

condition "user_exists" {
sql = "select count(*) > 0 from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value lets the program continue; falsy or NULL stops it gracefully.

script.condition attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

sql

SQL query whose single boolean (or 1/0) result is the guard.

truestring
script.condition constraints
ConstraintValue
Requiredfalse
Require Name (e.g., script.condition "name" )true
Repeatabletrue

script.exec

The mutation to run. The name label is optional and surfaces in logs.

script.exec attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

expect_rows

Expected number of rows affected by sql. Mismatch aborts the script.

falseint

sql

SQL statement (or batch) to execute.

truestring
script.exec constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.output

Emit a line of script output, e.g. "archived ${length(query.dormant.rows)} users". Unlike log (diagnostics), output is part of the script's result and is printed even by a quiet logger.

script.output attributes
Name and descriptionRequiredValue

message

The line to emit; may interpolate scope values, e.g. $\{length(query.<name>.rows)\}.

truestring
script.output constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.query

A read whose result later steps reference as query.<name>.rows[*].<col> (a list), .rows[N].<col> (one row), or length(query.<name>.rows).

query "batch" {
sql = "SELECT id, email FROM staging WHERE batch = ? ORDER BY id"
args = [iterator.range.from]
rows { id = int email = string }
}
script.query attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

sql

SQL query to run. Atlas binds args positionally and never rewrites it.

truestring
script.query blocks

script.query.rows

The result columns, declared as typed columns (name = <type>). Atlas reads only these columns, by name, and exposes them as query.<name>.rows[*].<col>.

script.query.rows constraints
ConstraintValue
Requiredtrue
Require Namefalse
Allow unknown attributestrue
script.query constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.tx

Transactional envelope for the script.

script.tx attributes
Name and descriptionRequiredValue

mode

Transaction mode.

false

enum (AUTO, NONE)

on_error

Behavior when the script errors.

false

enum (ROLLBACK, COMMIT)

script.exec constraints

ConstraintValue
Requiredfalse
Repeatabletrue

script loop

Batched/repeated loop: pre-loop condition gates, one iterator + one do body, post-loop assert/check, and an optional policy block (tx/schedule/ramp).

script.loop attributes

Name and descriptionRequiredValue

description

Free-form description; surfaced in audit logs.

falsestring

script.loop blocks

script.assert

An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).

assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.

script.assert attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Any value

error_message

Message returned to the user when the assertion fails.

falsestring

sql

SQL query whose single boolean (or 1/0) result is asserted.

truestring
script.assert constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.check

A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.

check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.check attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Any value

error_message

Message returned to the user when the check fails.

falsestring

format

Serialization format for the query output (CSV default, TABLE).

false

enum (CSV, TABLE)

match

Regular expression the output must match.

falsestring

output

Expected output, compared after trimming surrounding whitespace.

falsestring

sql

SQL query whose output is compared.

truestring
script.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

script.condition

A guard evaluated in textual order with the other steps. When its boolean SQL is not satisfied, the script stops gracefully at that point - committing the work done so far - without reporting a failure.

condition "user_exists" {
sql = "select count(*) > 0 from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value lets the program continue; falsy or NULL stops it gracefully.

script.condition attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Any value

sql

SQL query whose single boolean (or 1/0) result is the guard.

truestring
script.condition constraints
ConstraintValue
Requiredfalse
Require Name (e.g., script.condition "name" )true
Repeatabletrue

script.do

The per-iteration body. Same shape as an exec script; args may reference iterator.<mode>.* (e.g. batch). With tx.mode = MANUAL, wrap atomic statements in tx { } blocks.

script.do attributes
Name and descriptionRequiredValue

on_error

On a failing iteration: ABORT (default) stops the loop and surfaces the error; CONTINUE skips the iteration and proceeds. Rollback is decided by the tx structure.

false

enum (CONTINUE, ABORT)

script.do blocks

script.do.assert

An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).

assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.

script.do.assert attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

error_message

Message returned to the user when the assertion fails.

falsestring

sql

SQL query whose single boolean (or 1/0) result is asserted.

truestring
script.do.assert constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.break

Stop the loop when its boolean SQL is true - committing the work done so far this iteration, then running the post-loop assert/check.

break "disk_pressure" {
sql = "select pg_database_size(current_database()) > 5e11"
}
script.do.break attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

sql

Boolean SQL; when true (truthy), the loop stops.

truestring
script.do.break constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.check

A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.

check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.do.check attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

error_message

Message returned to the user when the check fails.

falsestring

format

Serialization format for the query output (CSV default, TABLE).

false

enum (CSV, TABLE)

match

Regular expression the output must match.

falsestring

output

Expected output, compared after trimming surrounding whitespace.

falsestring

sql

SQL query whose output is compared.

truestring
script.do.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

script.do.continue

Skip the rest of the current iteration when its boolean SQL is true - committing the work done so far - and advance to the next iteration.

continue "already_done" {
sql = "select count(*) = 0 from staging where batch = ?"
args = [iterator.range.from]
}
script.do.continue attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

sql

Boolean SQL; when true (truthy), skip to the next iteration.

truestring
script.do.continue constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.exec

The mutation to run. The name label is optional and surfaces in logs.

script.do.exec attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

expect_rows

Expected number of rows affected by sql. Mismatch aborts the script.

falseint

sql

SQL statement (or batch) to execute.

truestring
script.do.exec constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.http

Call an external HTTP endpoint (e.g. a service's deletion API that also cleans up blob storage). url/headers/body may interpolate scope like query.<name>.rows[*].id. Requires tx { mode = MANUAL } - a fired request cannot be rolled back.

http "del" {
url = var.deletion_endpoint
method = POST
body = jsonencode({ ids = query.batch.rows[*].id })
response = object({ data = object({ deleteUsers = object({ deleted = number }) }) })
}
script.do.http attributes
Name and descriptionRequiredValue

body

Request body, e.g. jsonencode({ ids = query.batch.rows[*].id }).

falsestring

ca_cert_pem

Certificate Authority (CA) in PEM format.

falsestring

client_cert_pem

Client certificate in PEM format.

falsestring

client_key_pem

Client key in PEM format.

falsestring

expect_status

Expected HTTP status code; a mismatch fails the step.

falseint

headers

Request headers, e.g. { Authorization = "Bearer ..." }.

falsemap

insecure

Disable verification of the server's certificate chain and hostname. Defaults to false.

falsebool

method

HTTP method (POST default).

false

enum (GET, POST, PUT, PATCH, DELETE)

request_timeout_ms

Request timeout in milliseconds.

falseint

response

Expected JSON response shape as a type, e.g. object({ data = object({ deleted = number }) }). The body is decoded into it with json.Unmarshal semantics (extra keys dropped, missing declared fields null) and exposed to later steps as http.<name>.<field>.

false

HCL type (string, number, bool, list(string), etc)

url

The endpoint URL. Supported schemes are http and https; Atlas calls it verbatim.

truestring
script.do.http blocks

script.do.http.check

Assert a boolean condition over the decoded response; a false or null result fails the step (and the loop, per on_error). No SQL - evaluated in-process.

check {
condition = length(http.del.errors) == 0
error_message = "deletion service returned errors"
}
script.do.http.check attributes
Name and descriptionRequiredValue

condition

Boolean expression over the response, e.g. length(http.<name>.errors) == 0. A false or null result fails the step.

true

Boolean condition over the response can be one of:

  1. List of object reference to http
  2. Any value

error_message

Message returned to the user when the condition fails.

falsestring
script.do.http.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.http.retry

Retry the request on a transient failure (a network error or a 5xx response).

script.do.http.retry attributes
Name and descriptionRequiredValue

attempts

Maximum number of retries after the first attempt.

falseint

max_delay_ms

Maximum backoff between attempts, in milliseconds.

falseint

min_delay_ms

Minimum backoff between attempts, in milliseconds.

falseint
script.do.http constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[ca_cert_pem, insecure]

script.do.log

Emit a line to the run log. message may interpolate scope values, e.g. "page ${self.index}".

script.do.log attributes
Name and descriptionRequiredValue

message

The line to log; may interpolate ${self.index}, ${iterator.<mode>.*}, etc.

truestring
script.do.log constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.output

Emit a line of script output, e.g. "archived ${length(query.dormant.rows)} users". Unlike log (diagnostics), output is part of the script's result and is printed even by a quiet logger.

script.do.output attributes
Name and descriptionRequiredValue

message

The line to emit; may interpolate scope values, e.g. $\{length(query.<name>.rows)\}.

truestring
script.do.output constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.query

A read whose result later steps reference as query.<name>.rows[*].<col> (a list), .rows[N].<col> (one row), or length(query.<name>.rows).

query "batch" {
sql = "SELECT id, email FROM staging WHERE batch = ? ORDER BY id"
args = [iterator.range.from]
rows { id = int email = string }
}
script.do.query attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. List of object reference to query
  4. List of object reference to http
  5. Any value

sql

SQL query to run. Atlas binds args positionally and never rewrites it.

truestring
script.do.query blocks

script.do.query.rows

The result columns, declared as typed columns (name = <type>). Atlas reads only these columns, by name, and exposes them as query.<name>.rows[*].<col>.

script.do.query.rows constraints
ConstraintValue
Requiredtrue
Require Namefalse
Allow unknown attributestrue
script.do.query constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.sleep

Pause for a fixed duration within the iteration, e.g. 500ms or 5s.

script.do.sleep attributes
Name and descriptionRequiredValue

duration

Go duration string, e.g. 500ms, 5s.

truestring
script.do.sleep constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.tx

An atomic group: the wrapped statements commit or roll back together. Requires the loop-level tx { mode = MANUAL }.

script.do.tx blocks

script.do.tx.assert

An assert runs inside the script's session and asserts a boolean SQL condition. A failing assertion aborts the script (and rolls back when tx.on_error = ROLLBACK).

assert "is_active" {
sql = "select status = 'active' from users where id = ?"
args = [var.id]
}

sql must return exactly one row, one boolean (or 1/0) column. A truthy value passes; falsy or NULL fails.

script.do.tx.assert attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. Any value

error_message

Message returned to the user when the assertion fails.

falsestring

sql

SQL query whose single boolean (or 1/0) result is asserted.

truestring
script.do.tx.assert constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.do.tx.check

A check runs a SQL query and compares its formatted output to an expected value or pattern - same shape as the exec block in atlas test.

check "user_count" {
sql = "select count(*) from users"
output = "1"
}
script.do.tx.check attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. Any value

error_message

Message returned to the user when the check fails.

falsestring

format

Serialization format for the query output (CSV default, TABLE).

false

enum (CSV, TABLE)

match

Regular expression the output must match.

falsestring

output

Expected output, compared after trimming surrounding whitespace.

falsestring

sql

SQL query whose output is compared.

truestring
script.do.tx.check constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[output, match]

script.do.tx.exec

The mutation to run. The name label is optional and surfaces in logs.

script.do.tx.exec attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to iterator
  2. List of object reference to references
  3. Any value

expect_rows

Expected number of rows affected by sql. Mismatch aborts the script.

falseint

sql

SQL statement (or batch) to execute.

truestring
script.do.tx.exec constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
script.do.tx constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
script.do constraints
ConstraintValue
Requiredtrue
Require Namefalse

script.iterator.keyset

Cursor-paginated iteration. Declare the seek cursor, optionally the exposed batch, and the init/next SELECTs Atlas threads the cursor through.

script.iterator.keyset blocks

script.iterator.batch

Optional. The page rows exposed to do as iterator.keyset.batch[*].<col>. Defaults to the cursor columns; declare it only to expose a different or extra set.

script.iterator.batch constraints
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue

script.iterator.cursor

The seek state, declared as typed columns (name = <type>). Atlas carries these across iterations and binds them as cursor.<col> in next.args.

cursor {
created_at = time
id = int
}
script.iterator.cursor constraints
ConstraintValue
Requiredtrue
Require Namefalse
Allow unknown attributestrue

script.iterator.init

The init page SELECT. It must return the cursor (and batch) columns; Atlas never rewrites it.

script.iterator.init attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql. next.args may reference cursor.<col>; both may reference self.index.

false

Positional bind values can be one of:

  1. List of object reference to cursor
  2. Any value

sql

The paginated SELECT - you own the ORDER BY, LIMIT, and seek predicate.

truestring
script.iterator.init constraints
ConstraintValue
Requiredtrue
Require Namefalse

script.iterator.next

The next page SELECT. It must return the cursor (and batch) columns; Atlas never rewrites it.

script.iterator.next attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql. next.args may reference cursor.<col>; both may reference self.index.

false

Positional bind values can be one of:

  1. List of object reference to cursor
  2. Any value

sql

The paginated SELECT - you own the ORDER BY, LIMIT, and seek predicate.

truestring
script.iterator.next constraints
ConstraintValue
Requiredtrue
Require Namefalse

script.iterator.range

Numeric range iteration. Atlas walks from..to in step-sized chunks, binding the current chunk as iterator.range.from/iterator.range.to in do.

script.iterator.range attributes
Name and descriptionRequiredValue

from

Inclusive lower bound of the range.

trueint

step

Chunk size: how far each iteration advances (>= 1). Defaults to 1.

falseint

to

Inclusive upper bound of the range.

trueint
script.iterator.range exposed references
NameValue
fromint
stepint
toint

script.policy

Operational policy for the loop: tx (transaction mode), schedule (cadence, bounds, back-pressure), and ramp (batch-size dial-up).

script.policy blocks

script.policy.ramp

Staged dial-up of the batch size: run small first (catch mistakes cheaply, watch the logs), then grow after each stage's hold. The current size is bound into the iterator SQL as ${ramp.size}.

ramp {
stage { size = 10 hold = "168h" } # week 1: tiny
stage { size = 500000 } # then full speed
}
script.policy.ramp blocks

script.policy.ramp.stage

One ramp step: a size held for iterations or hold before advancing.

script.policy.ramp.stage attributes
Name and descriptionRequiredValue

hold

Advance after this duration at this stage, e.g. 168h (mutually exclusive with iterations). The last stage needs neither.

falsestring

iterations

Advance after this many iterations at this stage (mutually exclusive with hold).

falseint

pause

Delay between iterations at this stage (overrides schedule.every), e.g. 10s.

falsestring

size

The chunk size for this stage, bound into the iterator SQL as ${ramp.size}.

trueint
script.policy.ramp.stage constraints
ConstraintValue
Requiredtrue
Require Namefalse
Repeatabletrue
Mutually exclusive sets[iterations, hold]

script.policy.schedule

How often and how long the loop runs: cadence, bounds, and back-pressure.

script.policy.schedule attributes
Name and descriptionRequiredValue

every

Fixed delay between iterations, e.g. 5m. Omit for back-to-back.

falsestring

limit

Maximum number of iterations before the loop stops.

falseint

pause_when

Boolean probe (one row, one boolean/1-0): while true the loop pauses and re-probes, then resumes. Back off on replica lag, lock waits, or queue depth.

falsestring

timeout

Wall-clock bound, e.g. 6h; the loop stops once exceeded.

falsestring

script.policy.tx

Transaction policy for the loop body.

script.policy.tx attributes
Name and descriptionRequiredValue

mode

PER_ITERATION (default) wraps each do iteration in one transaction; MANUAL leaves it unwrapped and lets do define its own tx { } blocks.

false

enum (PER_ITERATION, MANUAL)

script.loop constraints

ConstraintValue
Requiredfalse
Repeatabletrue

script query

Single-DB query script. Contains one or more query blocks; each runs in textual order and writes its result as a section of the output.

script.query attributes

Name and descriptionRequiredValue

description

Free-form description of the script.

falsestring

script.query blocks

script.mask

Redacts one or more columns of the query result before serialization. Select columns with columns and a method, or apply top-level named masks with use. At script level a mask applies to every query; a query's own mask wins (first match).

mask {
columns = ["email", "phone*"]
method = REDACT
}
mask { use = [mask.pii] }
script.mask attributes
Name and descriptionRequiredValue

char

PARTIAL: replacement character (default *).

falsestring

columns

Output columns to mask, matched case-sensitively; an entry with */?/[...] is a glob (schema include/exclude style).

false

List of strings

keep

PARTIAL: characters kept at each end (default 0).

falseint

keep_left

PARTIAL: characters kept at the start (overrides keep).

falseint

keep_right

PARTIAL: characters kept at the end (overrides keep).

falseint

match

REPLACE: regular expression matched against the value.

falsestring

method

Masking method (REDACT default).

false

enum (REDACT, PARTIAL, HASH, REPLACE)

salt

HASH: secret salt. With it the digest is a keyed HMAC-SHA256; without it a bare (unsalted) SHA256 digest, which is susceptible to dictionary attacks for low-entropy values. Stable salts yield comparable tokens; recommended for sensitive data.

falsestring

token

REDACT: replacement token (default ***).

falsestring

use

Top-level named masks to apply, e.g. [mask.pii].

false

List of object reference to mask

with

REPLACE: replacement for the matched substring.

falsestring
script.mask constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[use, columns], [use, method]

script.output

Emit a line of script output, e.g. "archived ${length(query.dormant.rows)} users". Unlike log (diagnostics), output is part of the script's result and is printed even by a quiet logger.

script.output attributes
Name and descriptionRequiredValue

message

The line to emit; may interpolate scope values, e.g. $\{length(query.<name>.rows)\}.

truestring
script.output constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.query

A single read. Runs sql, optionally redacts columns via mask blocks, and serializes the result per format as a section of the script's output. With a rows block it prints nothing; the result is bound for later blocks as query.<name>.rows[*].<col>.

query "user_by_id" {
sql = "select id, email from users where id = ?"
args = [var.id]
format = CSV
}
script.query attributes
Name and descriptionRequiredValue

args

Positional values bound to placeholders in sql.

false

Positional bind values can be one of:

  1. List of object reference to query
  2. Any value

format

Serialization format for this query's result (TABLE default).

false

enum (CSV, TABLE)

sql

SQL query to run.

truestring
script.query blocks

script.query.mask

Redacts one or more columns of the query result before serialization. Select columns with columns and a method, or apply top-level named masks with use. At script level a mask applies to every query; a query's own mask wins (first match).

mask {
columns = ["email", "phone*"]
method = REDACT
}
mask { use = [mask.pii] }
script.query.mask attributes
Name and descriptionRequiredValue

char

PARTIAL: replacement character (default *).

falsestring

columns

Output columns to mask, matched case-sensitively; an entry with */?/[...] is a glob (schema include/exclude style).

false

List of strings

keep

PARTIAL: characters kept at each end (default 0).

falseint

keep_left

PARTIAL: characters kept at the start (overrides keep).

falseint

keep_right

PARTIAL: characters kept at the end (overrides keep).

falseint

match

REPLACE: regular expression matched against the value.

falsestring

method

Masking method (REDACT default).

false

enum (REDACT, PARTIAL, HASH, REPLACE)

salt

HASH: secret salt. With it the digest is a keyed HMAC-SHA256; without it a bare (unsalted) SHA256 digest, which is susceptible to dictionary attacks for low-entropy values. Stable salts yield comparable tokens; recommended for sensitive data.

falsestring

token

REDACT: replacement token (default ***).

falsestring

use

Top-level named masks to apply, e.g. [mask.pii].

false

List of object reference to mask

with

REPLACE: replacement for the matched substring.

falsestring
script.query.mask constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[use, columns], [use, method]

script.query.rows

The result columns, declared as typed columns (name = <type>). Atlas reads only these columns, by name, and exposes them as query.<name>.rows[*].<col>.

script.query.rows constraints
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
script.query constraints
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

script.query constraints

ConstraintValue
Requiredfalse
Repeatabletrue