PROJECT_ID: the project that contains the
resource.
DATASET: the dataset that contains the
resource.
MODEL: The name of the model.
HORIZON: anINT64value that specifies the number of
time points to forecast. The default value is3, and the maximum value is
the value
of theHORIZONoption specified in theCREATE MODELstatement for time-series models, or1000if that option isn't specified.
When forecasting multiple time series at the same time, this parameter
applies to each time series.
CONFIDENCE_LEVEL: aFLOAT64value that specifies
percentage of the future values that fall in the prediction interval. The
default value is0.95. The valid input range is[0, 1).
TABLE: The name of the input table that contains the
features.
IfTABLEis specified, the input column names in the table must match the
column names in the model, and their types should be compatible according to
BigQueryimplicit coercion rules.
If there are unused columns from the table, they are ignored.
QUERY_STATEMENT: The GoogleSQL query that is
used to generate the features. See theGoogleSQL query syntaxpage for the supported SQL syntax of theQUERY_STATEMENTclause.
IfQUERY_STATEMENTis specified, the input column names from the query
must match the column names in the model, and their types should be
compatible according to BigQueryimplicit coercion rules.
If there are unused columns from the query, they are ignored.
Output
ML.FORECASTreturns the following columns:
time_series_id_colortime_series_id_cols: a value that contains
the identifiers of a time series.time_series_id_colcan be anINT64orSTRINGvalue.time_series_id_colscan be anARRAY<INT64>orARRAY<STRING>value. Only present when forecasting multiple time series at
once. The column names and types are inherited from theTIME_SERIES_ID_COLoption as specified in theCREATE MODELstatement.
forecast_timestamp: aTIMESTAMPvalue that contains the timestamps of a
time series.
forecast_value: aFLOAT64value that contains the average of theprediction_interval_lower_boundandprediction_interval_upper_boundvalues.
standard_error: aFLOAT64value that contains the amount of variability
in the estimated results.
confidence_level: aFLOAT64value that contains theconfidence_levelvalue you specified in the function input, or0.95if you didn't
specify aconfidence_levelvalue. It is the same across all rows.
prediction_interval_lower_bound: aFLOAT64value that contains the lower
bound of the prediction interval for each forecasted point.
prediction_interval_upper_bound: aFLOAT64value that contains the upper
bound of the prediction interval for each forecasted point.
confidence_interval_lower_bound: aFLOAT64value that contains the
lower bound of the confidence interval for each forecasted point.
confidence_interval_upper_bound: aFLOAT64value that contains the upper
bound of the confidence interval for each forecasted point.
The output ofML.FORECASThas the following properties:
For each time series, the output rows are sorted in the chronological order offorecast_timestamp.
forecast_timestampalways has a type ofTIMESTAMP, regardless of the type
of the column specified in theTIME_SERIES_TIMESTAMP_COLoptionof theCREATE MODELstatement.
ARIMA_PLUSexample
The following example forecasts 30 time points with a
confidence level of0.8:
Applying any additional computation on top ofML.FORECAST's result
columns might lead to an out of memory error if the model size is too large. If this happens, you might see errors likeResources exceeded during query execution: The query could not be executed in the allotted memory.
Examples of operations that might cause this issue are calculating minimum or maximum values, or adding to or subtracting
from a particular column. If you are trying to filter on the forecasted value,
we recommend that you use theforecast with limitoption instead, because the algorithm it uses is less likely to cause an issue. If you keep getting out of memory errors, you can try working around this issue by
creating a new table for theML.FORECASTresult, and then applying other computations in a different query that uses data from the new table.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-29 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eML.FORECAST\u003c/code\u003e function forecasts a time series using a trained \u003ccode\u003eARIMA_PLUS\u003c/code\u003e or \u003ccode\u003eARIMA_PLUS_XREG\u003c/code\u003e model.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts arguments like \u003ccode\u003ehorizon\u003c/code\u003e (number of time points to forecast) and \u003ccode\u003econfidence_level\u003c/code\u003e (percentage of future values within the prediction interval) with defaults of 3 and 0.95, respectively.\u003c/p\u003e\n"],["\u003cp\u003eFor \u003ccode\u003eARIMA_PLUS_XREG\u003c/code\u003e models, you must provide a table or query statement containing the future features for forecasting.\u003c/p\u003e\n"],["\u003cp\u003eThe output includes columns such as \u003ccode\u003eforecast_timestamp\u003c/code\u003e, \u003ccode\u003eforecast_value\u003c/code\u003e, and prediction interval bounds, providing a detailed forecast with error and confidence metrics.\u003c/p\u003e\n"],["\u003cp\u003eApplying extra calculations to the columns returned by the \u003ccode\u003eML.FORECAST\u003c/code\u003e function can lead to out of memory errors, so it is recommended to create a new table from the result of the function and to use it in further queries.\u003c/p\u003e\n"]]],[],null,["# The ML.FORECAST function\n========================\n\nThis document describes the `ML.FORECAST` function, which you can use to\nforecast a time series based on a trained `ARIMA_PLUS` or `ARIMA_PLUS_XREG`\nmodel.\n\nIf you don't want to manage your own times series forecasting model, you can\nuse the\n[`AI.FORECAST` function](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast)\nwith BigQuery ML's built-in\n[TimesFM time series model](/bigquery/docs/timesfm-model)\n([Preview](/products#product-launch-stages)) to perform forecasting.\n\nSyntax\n------\n\n # ARIMA_PLUS models:\n ML.FORECAST(\n MODEL `PROJECT_ID.DATASET.MODEL_NAME`,\n STRUCT(\n [, HORIZON AS horizon]\n [, CONFIDENCE_LEVEL AS confidence_level])\n )\n\n # ARIMA_PLUS_XREG model:\n ML.FORECAST(\n MODEL `PROJECT_ID.DATASET.MODEL_NAME`,\n [{ TABLE `PROJECT_ID.DATASET.TABLE` | (QUERY_STATEMENT) } ,]\n STRUCT(\n HORIZON AS horizon,\n CONFIDENCE_LEVEL AS confidence_level)\n )\n\n### Arguments\n\n`ML.FORECAST` takes the following arguments:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project that contains the resource.\n- \u003cvar translate=\"no\"\u003eDATASET\u003c/var\u003e: the dataset that contains the resource.\n- \u003cvar translate=\"no\"\u003eMODEL\u003c/var\u003e: The name of the model.\n- \u003cvar translate=\"no\"\u003eHORIZON\u003c/var\u003e: an `INT64` value that specifies the number of\n time points to forecast. The default value is `3`, and the maximum value is\n the value\n of the `HORIZON` option specified in the\n [`CREATE MODEL`](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-time-series)\n statement for time-series models, or `1000` if that option isn't specified.\n When forecasting multiple time series at the same time, this parameter\n applies to each time series.\n\n | **Note:** Forecasting takes place when the [`CREATE MODEL` statement](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-time-series) runs. `ML.FORECAST` just retrieves the forecasting values and computes the prediction intervals. Therefore, this argument exists mainly for filtering results when forecasting multiple time series. To save query time, you should specify a value for the `HORIZON` option in the `CREATE MODEL` statement.\n- \u003cvar translate=\"no\"\u003eCONFIDENCE_LEVEL\u003c/var\u003e: a `FLOAT64` value that specifies\n percentage of the future values that fall in the prediction interval. The\n default value is `0.95`. The valid input range is `[0, 1)`.\n\n- \u003cvar translate=\"no\"\u003eTABLE\u003c/var\u003e: The name of the input table that contains the\n features.\n\n If `TABLE` is specified, the input column names in the table must match the\n column names in the model, and their types should be compatible according to\n BigQuery [implicit coercion rules](/bigquery/docs/reference/standard-sql/conversion_rules#coercion).\n\n If there are unused columns from the table, they are ignored.\n- \u003cvar translate=\"no\"\u003eQUERY_STATEMENT\u003c/var\u003e: The GoogleSQL query that is\n used to generate the features. See the\n [GoogleSQL query syntax](/bigquery/docs/reference/standard-sql/query-syntax#sql_syntax)\n page for the supported SQL syntax of the `QUERY_STATEMENT` clause.\n\n If `QUERY_STATEMENT` is specified, the input column names from the query\n must match the column names in the model, and their types should be\n compatible according to BigQuery\n [implicit coercion rules](/bigquery/docs/reference/standard-sql/conversion_rules#coercion).\n\n If there are unused columns from the query, they are ignored.\n\nOutput\n------\n\n`ML.FORECAST` returns the following columns:\n\n- `time_series_id_col` or `time_series_id_cols`: a value that contains the identifiers of a time series. `time_series_id_col` can be an `INT64` or `STRING` value. `time_series_id_cols` can be an `ARRAY\u003cINT64\u003e` or `ARRAY\u003cSTRING\u003e` value. Only present when forecasting multiple time series at once. The column names and types are inherited from the `TIME_SERIES_ID_COL` option as specified in the `CREATE MODEL` statement.\n- `forecast_timestamp`: a `TIMESTAMP` value that contains the timestamps of a time series.\n- `forecast_value`: a `FLOAT64` value that contains the average of the `prediction_interval_lower_bound` and `prediction_interval_upper_bound` values.\n- `standard_error`: a `FLOAT64` value that contains the amount of variability in the estimated results.\n- `confidence_level`: a `FLOAT64` value that contains the `confidence_level` value you specified in the function input, or `0.95` if you didn't specify a `confidence_level` value. It is the same across all rows.\n- `prediction_interval_lower_bound`: a `FLOAT64` value that contains the lower bound of the prediction interval for each forecasted point.\n- `prediction_interval_upper_bound`: a `FLOAT64` value that contains the upper bound of the prediction interval for each forecasted point.\n- `confidence_interval_lower_bound`: a `FLOAT64` value that contains the lower bound of the confidence interval for each forecasted point.\n- `confidence_interval_upper_bound`: a `FLOAT64` value that contains the upper bound of the confidence interval for each forecasted point.\n\nThe output of `ML.FORECAST` has the following properties:\n\n- For each time series, the output rows are sorted in the chronological order of `forecast_timestamp`.\n- `forecast_timestamp` always has a type of `TIMESTAMP`, regardless of the type of the column specified in the [`TIME_SERIES_TIMESTAMP_COL` option](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-time-series#time_series_timestamp_col) of the `CREATE MODEL` statement.\n\n`ARIMA_PLUS` example\n--------------------\n\nThe following example forecasts 30 time points with a\nconfidence level of `0.8`: \n\n```sql\nSELECT\n *\nFROM\n ML.FORECAST(MODEL `mydataset.mymodel`,\n STRUCT(30 AS horizon, 0.8 AS confidence_level))\n```\n\n`ARIMA_PLUS_XREG` example\n-------------------------\n\nThe following example forecasts 30 time points with a\nconfidence level of `0.8` with future features: \n\n```sql\nSELECT\n *\nFROM\n ML.FORECAST(MODEL `mydataset.mymodel`,\n STRUCT(30 AS horizon, 0.8 AS confidence_level),\n (SELECT * FROM `mydataset.mytable`))\n```\n\nLimitation\n----------\n\nApplying any additional computation on top of `ML.FORECAST`'s result\ncolumns might lead to an out of memory error if the model size is too large. If this happens, you might see errors like\n`Resources exceeded during query execution: The query could not be executed in the allotted memory`.\nExamples of operations that might cause this issue are calculating minimum or maximum values, or adding to or subtracting\nfrom a particular column. If you are trying to filter on the forecasted value,\nwe recommend that you use the [forecast with limit](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create-time-series#forecast_limit_lower_bound) option instead, because the algorithm it uses is less likely to cause an issue. If you keep getting out of memory errors, you can try working around this issue by\ncreating a new table for the `ML.FORECAST` result, and then applying other computations in a different query that uses data from the new table.\n\nWhat's next\n-----------\n\n- For information about model inference, see [Model inference overview](/bigquery/docs/inference-overview).\n- For information about the supported SQL statements and functions for each model type, see [End-to-end user journey for each model](/bigquery/docs/e2e-journey)."]]