feat: Update bigquery.ai.generate_table output_schema to allow Mappin… · google/bigframes@f7fd189 · GitHub
Skip to content

Commit f7fd189

Browse files
authored
feat: Update bigquery.ai.generate_table output_schema to allow Mapping type (#2463)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent ca9fb13 commit f7fd189

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

bigframes/bigquery/_operations/ai.py

Lines changed: 15 additions & 4 deletions

tests/system/large/bigquery/test_ai.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,20 @@ def test_generate_table(text_model):
111111
assert "creator" in result.columns
112112
# The model may not always return the exact number of rows requested.
113113
assert len(result) > 0
114+
115+
116+
def test_generate_table_with_mapping_schema(text_model):
117+
df = bpd.DataFrame(
118+
{"prompt": ["Generate a table of 2 programming languages and their creators."]}
119+
)
120+
121+
result = ai.generate_table(
122+
text_model,
123+
df,
124+
output_schema={"language": "STRING", "creator": "STRING"},
125+
)
126+
127+
assert "language" in result.columns
128+
assert "creator" in result.columns
129+
# The model may not always return the exact number of rows requested.
130+
assert len(result) > 0

tests/unit/bigquery/test_ai.py

Lines changed: 26 additions & 0 deletions

0 commit comments

Comments
 (0)