fix(bigquery): support AI.FORECAST TVF parsing#7457
Merged
georgesittas merged 1 commit intotobymao:mainfrom Apr 6, 2026
Merged
fix(bigquery): support AI.FORECAST TVF parsing#7457georgesittas merged 1 commit intotobymao:mainfrom
georgesittas merged 1 commit intotobymao:mainfrom
Conversation
Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
georgesittas
approved these changes
Apr 6, 2026
Collaborator
georgesittas
left a comment
There was a problem hiding this comment.
I think this can be cleaned up a bit, but I'll take it to the finish line. Thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This PR adds BigQuery parser/generator support for
AI.FORECASTtable valued function syntax.The current
mainparsesML.FORECAST(...)but fails on documentedAI.FORECAST(...)TVF forms with named arguments.Resolves #7456.
Changes done:
AIForecastexpression:sqlglot/expressions/functions.pyAIForecast:sqlglot/generator.pyTABLE <name>prefix for table input, while keeping parenthesized query input unchanged.FORECASTfunction parser routing:sqlglot/parsers/bigquery.pyML.FORECASTstill uses existing ML parser path.FORECAST(forAI.FORECAST) now parses TVF first arg (TABLE <table>or(SELECT ...)) plus named args.tests/dialects/test_bigquery.pyAI.FORECAST(TABLE citibike_trips, data_col => 'num_trips', timestamp_col => 'date', horizon => 30)AI.FORECAST((SELECT * FROM citibike_trips), data_col => 'num_trips', timestamp_col => 'date', horizon => 30)Validation:
Executed in WSL:
python -m pytest -q tests/dialects/test_bigquery.py -k "ml_functions"Result:
1 passed, 57 deselected.The screenshot of the focused test suite run, locally, on WSL for validation:
Ran the full test suite, locally on WSL for validation:
Result:
1074 passed in 57.76s.The screenshot of the full test suite run, locally, on WSL for validation: