Skip to content

Commit

Permalink
Merge pull request #10 from Ki-Insurance/set-lifetime-for-feast-tmp-t…
Browse files Browse the repository at this point in the history
…ables

Set lifetime for feast_tmp tables
  • Loading branch information
crispin-ki authored Aug 1, 2023
2 parents 2fa6d5a + bcb9dbc commit 7af776a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,15 @@ def to_bigquery(
temp_dest_table = f"{tmp_dest['projectId']}.{tmp_dest['datasetId']}.{tmp_dest['tableId']}"

# persist temp table
sql = f"CREATE TABLE `{dest}` AS SELECT * FROM {temp_dest_table}"
# added expiration to table: https://stackoverflow.com/a/50227484
# as in bytewax materialization, these tables are not otherwise deleted
sql = f"""
CREATE TABLE `{dest}`
OPTIONS(
expiration_timestamp=TIMESTAMP_ADD(CURRENT_TIMESTAMP(), INTERVAL 3 DAY)
)
AS SELECT * FROM {temp_dest_table}
"""
self._execute_query(sql, timeout=timeout)

print(f"Done writing to '{dest}'.")
Expand Down

0 comments on commit 7af776a

Please sign in to comment.