On this page

Macros

Reference for Statsig Warehouse Native query tools that help you inspect generated SQL, debug data sources, and validate metric and experiment configuration.

In Metric and Assignment sources, you can use Statsig Macros to directly inject a DATE() type that is relative to the experiment period being loaded.

  • {statsig_start_date}
  • {statsig_end_date}

For example, in an incremental reload from 2023-09-01 to 2023-09-03, this query:

sql
SELECT
    user_id,
    event,
    ts,
    dt
FROM log_table
WHERE dt BETWEEN `{statsig_start_date}` AND `{statsig_end_date}`

resolves to

sql
SELECT
    user_id,
    event,
    ts,
    dt
FROM log_table
WHERE dt BETWEEN DATE('2023-09-01') AND DATE('2023-09-03')

This is useful because you can inject filters into queries with joins or CTEs and confirm that the initial scan is pruned.

Statsig adjusts the range as necessary in some cases. For example, in entity properties, Statsig adds a pre-experiment buffer to allow for late-landing property data, then selects the most recent value as of each unit's exposure. For CUPED, Statsig adjusts the range to include the pre-experiment window for CUPED calculations.

Timezone note

All timestamps in Warehouse Native from Statsig are in UTC, and Statsig assumes timestamps in the warehouse are timezone-less/UTC as well.

Advanced macros

  • {statsig_start_date_int}

  • {statsig_end_date_int} Int versions of the above for use with number based partitioning - e.g. '2025-03-01' => 20250301

  • {statsig_experiment_start_timestamp} Only available for metric sources and entity property sources; this resolves to the start timestamp of the experiment. In non-experiment contexts, it resolves to TIMESTAMP('1970-01-01'). This is useful for generating entity properties such as "30d revenue before the experiment started".

Was this helpful?