Skip to content

feat(bigframes): add AI TVFs to the pandas bq accessor#17402

Open
sycai wants to merge 1 commit into
mainfrom
sycai_ai_generate_tvf
Open

feat(bigframes): add AI TVFs to the pandas bq accessor#17402
sycai wants to merge 1 commit into
mainfrom
sycai_ai_generate_tvf

Conversation

@sycai

@sycai sycai commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Also updated the tests to fully utilize the mocking framework.

internal issue: b/517233441

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds generate_embedding, generate_text, and generate_table accessor methods to the BigQuery DataFrame accessor, along with comprehensive unit tests. The feedback suggests removing pd.Series from the type annotations of the model parameter in these new methods, as BigQuery ML models cannot be pandas Series.

Comment thread packages/bigframes/bigframes/extensions/core/dataframe_accessor.py
Comment thread packages/bigframes/bigframes/extensions/core/dataframe_accessor.py
Comment thread packages/bigframes/bigframes/extensions/core/dataframe_accessor.py
@sycai sycai requested review from TrevorBergeron and tswast June 9, 2026 00:47
@sycai sycai marked this pull request as ready for review June 9, 2026 00:47
@sycai sycai requested review from a team as code owners June 9, 2026 00:47
)
return self._to_series(result)

def generate_embedding(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this acts only on a single column (called "content"), I think the Series accessor would be a much better fit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Let me move the contents to the series accessor

)
return self._to_dataframe(result)

def generate_text(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This acts on a single "prompt" column. I think Series accessor would be a better fit.

To avoid conflicts with generated code, please use a "mixin" pattern to avoid conflicts between the generated Series code and these methods: https://adamj.eu/tech/2025/05/01/python-type-hints-mixin-classes/

)
return self._to_dataframe(result)

def generate_table(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This acts on a single "prompt" column and would be better suited as a series accessor method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants