Values of the call

Some inputs are not the caller's to give. The time a request is served at must not be supplied by the client, and neither should the random draw that assigns it to an experiment. USING binds such an input to a value the server makes on each call:

  • REQ_TS := REQUEST_TIME(): the time the server received the call, a TIMESTAMP in UTC.
  • REQ_SEED := REQUEST_SEED(): a DOUBLE drawn uniformly in [0, 1) for the call.

Take a feature that reads one caller input, FEATURE_A, and two of these:

FeatureQL
CREATE OR REPLACE FEATURES IN FM.TUTORIALS.PREPARED_STATEMENTS AS
PERSIST
    req_ts := INPUT(TIMESTAMP),
    req_seed := INPUT(DOUBLE),
    call_check := ROW(
        feature_a + 1 AS next_a,
        req_ts >= TIMESTAMP '2026-01-01 00:00:00' AS called_after_2026,
        req_seed >=.15 0.0 AND req_seed <.15 1.0 AS seed_in_unit_range
    ),
    called_after_2026 := req_ts >= TIMESTAMP '2026-01-01 00:00:00'
;
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026CREATEDFeature created as not exists
FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECKCREATEDFeature created as not exists
FM.TUTORIALS.PREPARED_STATEMENTS.REQ_SEEDCREATEDFeature created as not exists
FM.TUTORIALS.PREPARED_STATEMENTS.REQ_TSCREATEDFeature created as not exists

>=.15 and <.15 compare a DOUBLE at 15 decimals: a bare >= does the same and warns ( Decision tables ).

The prepared statement lists FEATURE_A as a parameter and binds the other two:

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK_PS AS
PREPARED_STATEMENT(
    FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK
    USING (
        FM.TUTORIALS.PREPARED_STATEMENTS.FEATURE_A,
        FM.TUTORIALS.PREPARED_STATEMENTS.REQ_TS := REQUEST_TIME(),
        FM.TUTORIALS.PREPARED_STATEMENTS.REQ_SEED := REQUEST_SEED()
    )
);
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK_PSCREATEDFeature created as not exists

Bound inputs take no place in the input tables: input_1 holds FEATURE_A alone. Their values come back with each row, so a caller can log the time and seed its answer was computed with:

Prepared
FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK_PS
Call 1
{"input_1": [[1], [5]]}
FEATURE_A BIGINTREQ_TS VARCHARREQ_SEED VARCHARCALL_CHECK_PS ROW
1**{next_a: 2, called_after_2026: true, seed_in_unit_range: true}
5**{next_a: 6, called_after_2026: true, seed_in_unit_range: true}

When every input is bound, the statement takes no input table at all. The request is an empty object, and the answer is one row:

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026_PS AS
PREPARED_STATEMENT(
    FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026
    USING FM.TUTORIALS.PREPARED_STATEMENTS.REQ_TS := REQUEST_TIME()
);
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026_PSCREATEDFeature created as not exists

Prepared
FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026_PS
Call 1
{}
REQ_TS VARCHARCALLED_AFTER_2026_PS BOOLEAN
*true

USING binds REQUEST_TIME() and REQUEST_SEED() as they are. An expression of them, such as a time one day earlier, is a feature computed from the bound input:

FeatureQL
CREATE OR REPLACE FEATURE FM.TUTORIALS.PREPARED_STATEMENTS.YESTERDAY_PS AS
PREPARED_STATEMENT(
    FM.TUTORIALS.PREPARED_STATEMENTS.CALLED_AFTER_2026
    USING FM.TUTORIALS.PREPARED_STATEMENTS.REQ_TS := REQUEST_TIME() - INTERVAL '1 day'
);
Result
ERROR UE/PREPARED-STATEMENT-USING-BINDER

Write YESTERDAY := REQ_TS - INTERVAL '1 day' as a feature, and bind REQ_TS := REQUEST_TIME().

The server sends these values to the engine in a request field of its own, call_context. A request that fills it is refused, so the time and the draw are always the server's:

Prepared
FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK_PS
Call 1
{"input_1": [[1]], "call_context": [["2026-06-01 00:00:00", 0.5]]}
FEATURE_A BIGINTREQ_TS VARCHARREQ_SEED VARCHARCALL_CHECK_PS ROW
ERROR SERVER_FILLED_PARAMETER

One draw per call, or per key

REQUEST_SEED() is drawn once per call: every row of a call reads the same REQ_SEED. For a draw of each key in a batch call, hash the key with the seed:

IN_TREATMENT := HASH01(USER_ID::VARCHAR || '/' || REQ_SEED::VARCHAR) <.2 0.10e0

That draw changes from call to call. For a key that lands on the same side on every call, as a rollout needs, hash the key with a fixed salt instead ( Roll out a changed rule ).

Replaying a call

Since the bound values come back with the answer, a logged call can be replayed exactly. A free-form query binds the same inputs to the logged values:

RETURN FM.TUTORIALS.PREPARED_STATEMENTS.CALL_CHECK
FOR CROSS
    FM.TUTORIALS.PREPARED_STATEMENTS.FEATURE_A := BIND_VALUES(ARRAY(1, 5)),
    FM.TUTORIALS.PREPARED_STATEMENTS.REQ_TS := BIND_VALUES(ARRAY(TIMESTAMP '2026-11-11 09:30:00')),
    FM.TUTORIALS.PREPARED_STATEMENTS.REQ_SEED := BIND_VALUES(ARRAY(0.4218e0));

The same query runs on any backend, so the features served in real time can be recomputed in batch for the logged calls.

Prepared statements covers USING and the call itself.