san.execute_sql(query="""
SELECT
get_metric_name(metric_id) AS metric,
get_asset_name(asset_id) AS asset,
dt,
argMax(value, computed_at)
FROM daily_metrics_v2
WHERE
asset_id = get_asset_id({{slug}}) AND
metric_id = get_metric_id({{metric}}) AND
dt >= now() - INTERVAL {{last_n_days}} DAY
GROUP BY dt, metric_id, asset_id
ORDER BY dt ASC
""",
parameters={'slug': 'bitcoin', 'metric': 'daily_active_addresses', 'last_n_days': 7},
set_index="dt")
Add helper functions to easily execute SQL: