googleapis / googleapis/google-cloud-python

Default expiration date is added to created table with a `TimePartitioning` when `expiration_ms` is explicitly none

未關閉
#15,741 14 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

@chalmerlowe 已經在處理了。

開始於 2026年1月12日。

api: bigquery external status: blocked type: feature request
主要語言
Python
星號
5.4k
分支
1.8k
平均合併
2 天 23 小時
30 天內合併 PR
123

描述

Environment details
  • OS type and version: Windows 10
  • Python version: 3.9.0
  • pip version: 21.1
  • google-cloud-bigquery version: 2.13.1
Steps to reproduce / Code example

When running the following code a table is where the value of Partition Expiration is silently set to the default expiration date defined on the dataset.

from google.cloud.bigquery import (
    Table,
    SchemaField,
    TimePartitioning,
    TimePartitioningType,
)

table = Table(
    f"project.dataset.test_table",
    schema=[
        SchemaField("test", "STRING", "NULLABLE"),
        SchemaField("date", "TIMESTAMP"),
    ]
)
table.time_partitioning = TimePartitioning(
    TimePartitioningType.DAY, field="date", expiration_ms=None,
)

# bq being an already configured instance of google.cloud.bigquery.Client
bq.create_table(table)

To start it is good to note that the way to remove an expiration date (fully remove, not set to default) from a partition via the standard SQL is as follows:

ALTER TABLE ropo.orders 
SET OPTIONS (partition_expiration_days=NULL)

So even though you explicitly seem to set the expiration_ms to "no expiration date" in the code it will still silently remove the table after time x (depending on the dataset). The field expiration_ms only accepts None and positive integers, therefore, when the dataset does have one by default, there is no way to create the table with a TimePartition but without an expiration_date at all. Values like 0, null, and NULL will all throw an error.

I would advise changing the behavior as follows:

Set the default_values of some variable that is given the name DEFAULT_PARTITION_EXPIRATION_FROM_DATASET such that this behavior is clear from the function definition. Don't make the value of the variable None such that we still have this variable available to explicitly turn the expiration functionality off.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。