Skip to content

Conversation

@jialuoo
Copy link
Contributor

@jialuoo jialuoo commented Oct 15, 2025

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 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 b/450913424 🦕

@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Oct 15, 2025
@jialuoo jialuoo marked this pull request as ready for review October 16, 2025 20:16
@jialuoo jialuoo requested review from a team as code owners October 16, 2025 20:16
Comment on lines +81 to +97
def _cleanup_old_udfs(self):
"""Clean up old UDFs in the anonymous dataset."""
dataset = self._session._anon_dataset_manager.dataset
routines = list(self._session.bqclient.list_routines(dataset))
cleanup_cutoff_time = datetime.datetime.now(
datetime.timezone.utc
) - datetime.timedelta(days=_UDF_CLEANUP_THRESHOLD_DAYS)

for routine in routines:
if (
routine.created < cleanup_cutoff_time
and routine._properties["routineType"] == "SCALAR_FUNCTION"
):
try:
self._session.bqclient.delete_routine(routine.reference)
except Exception:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems this code should just be in the AnonymousDatasetManager itself? Also, are we sure on the timing of when we want to trigger this?

Copy link
Contributor

@TrevorBergeron TrevorBergeron left a comment

Choose a reason for hiding this comment

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

Also, maybe some tests to validate the behavior?

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

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants