Skip to content

Current delay

The current_delay sensor calculates the timestamp difference between last record (the newest one appointed by MAX() function) and a CURRENT_TIMESTAMP().


Jinja Template

{% import '/dialects/bigquery.sql.jinja2' as lib with context -%}
SELECT
    {{ lib.render_current_timestamp_diff(parameters.column, parameters.time_scale) }} AS actual_value
    {{- lib.render_dimension_projections('analyzed_table') }}
    {{- lib.render_time_dimension_projection('analyzed_table') }}
FROM {{ lib.render_target_table() }} AS analyzed_table
{{- lib.render_where_clause() -}}
{{- lib.render_group_by() -}}
{{- lib.render_order_by() -}}
{% import '/dialects/snowflake.sql.jinja2' as lib with context -%}
SELECT
    {{ lib.render_current_timestamp_diff(parameters.column, parameters.time_scale) }} AS actual_value
    {{- lib.render_dimension_projections('analyzed_table') }}
    {{- lib.render_time_dimension_projection('analyzed_table') }}
FROM {{ lib.render_target_table() }} AS analyzed_table
{{- lib.render_where_clause() -}}
{{- lib.render_group_by() -}}
{{- lib.render_order_by() -}}