BigQuery ML.TREND can use later data to smooth a historical point
For an as-of report or backtest, apply the cutoff to the input of ML.TREND, not just to the rows it returns.
Ask a SQL assistant, “What did the daily sign-up trend look like as of Friday?” and it might run BigQuery’s ML.TREND on the full table, then filter the result to Friday. That produces a chart that ends on Friday, but it does not necessarily reproduce what someone could have known on Friday. The distinction follows from how BigQuery documents ML.TREND: its default smoothing window is five points, and that smoothing is centered on each historical trend point.
‘History’ describes the row, not the information available then
With a five-point centered average, an interior point uses two trend points on either side. For a daily series, that means a Friday surrounded by a full window can be smoothed using Saturday and Sunday trend points. As a toy example, if the five pre-smoothing trend values from Wednesday through Sunday were 10, 10, 10, 20 and 20, their centered average at Friday would be 14. That is arithmetic illustrating the documented window, not a measured BigQuery result or an assertion that ML.TREND averages the raw observations directly. Google distinguishes the calculated trend column from the input data column in its output schema.
Omitting horizon makes the function return historical results only. Likewise, filtering time_series_type to history keeps forecast rows out of the result. Neither action puts a cutoff on the input. Google also documents that the smoother pads the first or last value at the series boundary, so Friday at the end of a Friday-only run is not treated the same way as an interior Friday in a run that includes the weekend.
Put the cutoff where the function reads it
For a single as-of report, make the cutoff part of the table or query passed into ML.TREND. If observations can arrive late or be revised, use a snapshot or an availability timestamp that reflects what the analyst could actually have seen at that cutoff; filtering by observation date alone does not establish that. For a backtest that simulates a decision on each date, repeat the calculation with the input available at each decision date, or choose a separately validated trailing measure. A single fit through month-end should not be treated as a point-in-time feature for every day in that month.
A retrospective chart can still use centered smoothing. The practical review question is whether the user asked what the trend looks like in hindsight or what was knowable at the time. Check the input to the function, not just the dates in the final chart.
sources
- Google Cloud: The ML.TREND functiondocs.cloud.google.com
comments · 0
- EKOS’s pending BIRD submission pairs a SQLite-tuned run with a separate hidden-test scoreDec 3, 2026
- MotherDuck rolls out DuckDB 2.0 and reports faster cold reads, not faster agent answersDec 3, 2026
- Oracle Select AI can use two definitions of the same metric. Source order won’t break the tieDec 3, 2026