You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6c376b7
Browse filesBrowse the repository at this point in the historyBrowse files
fix(forecast): resolve time grain robustly for Prophet forecasting
Enabling Forecast (Advanced Analytics) on a time-series chart could fail
with the opaque error `prophet() missing 1 required positional argument:
'time_grain'` (SC-113749, follow-up to SC-111157 / #41180).
Root cause
----------
The `prophet` post-processing op is dispatched in
`QueryObject.exec_post_processing` via
`getattr(pandas_postprocessing, operation)(df, **options)`. The frontend
`prophetOperator` set `time_grain: formData.time_grain_sqla`; when that is
`undefined` (a saved/dashboard chart whose Time Grain was cleared to
"None", or a chart using the generic x-axis where the grain lives on the
adhoc column's `timeGrain` popover instead of the panel control),
`JSON.stringify` drops the key. The options dict then reaches the backend
without `time_grain`, so Python raises a raw `TypeError` at call time —
before the graceful `if not time_grain: raise InvalidPostProcessingError`
guard inside `prophet()` can run (yielding a 500 instead of a readable
4xx).
Reproduced
----------
- Backend: `prophet(df, periods=3, confidence_interval=0.9,
index="__timestamp")` (no `time_grain`) raised the exact customer
`TypeError`.
- Frontend: `prophetOperator` with `time_grain_sqla` absent from formData
emitted `time_grain: undefined`.
Fix
---
- Backend (robustness): make `time_grain` an optional kwarg
(`Optional[str] = None`, reordered after the required positional args)
so any code path missing a grain now surfaces the readable
"Time grain missing" `InvalidPostProcessingError` instead of a
`TypeError`.
- Frontend (make the feature work): resolve the effective grain in order
— adhoc x-axis column `timeGrain`, `queryObject.extras.time_grain_sqla`
(picks up dashboard-applied grains), then `formData.time_grain_sqla`,
with a final `P1D` fallback matching the `time_grain_sqla` control
default so a grain-less chart still forecasts.
Tests
-----
- Backend: added dispatch-path and explicit-`None` cases to
`tests/unit_tests/pandas_postprocessing/test_prophet.py`.
- Frontend: added fallback, adhoc-column, and extras resolution cases to
`prophetOperator.test.ts`.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
0 commit comments