-
Notifications
You must be signed in to change notification settings - Fork 49
feat: allow setting table labels in to_gbq
#941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6257ad7
60a542a
f5e8432
2f11e54
c6acd75
b506c4c
db31624
0b09216
de4e416
44775d5
c30c52a
35b891e
81bb23b
1a291ee
62e2627
2d8b220
8982149
dfd1c3a
efd48b6
9084327
1c09f7d
9ae5546
90618f6
9f0dc25
84342f1
9f08c6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4657,6 +4657,17 @@ def test_to_gbq_and_create_dataset(session, scalars_df_index, dataset_id_not_cre | |
assert not loaded_scalars_df_index.empty | ||
|
||
|
||
def test_to_gbq_table_labels(scalars_df_index): | ||
destination_table = "bigframes-dev.bigframes_tests_sys.table_labels" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally the test should not be hard coupled with a project/dataset. Do we have to use a fixed table name? I think the test would still serve its purpose if we did There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in #968! |
||
result_table = scalars_df_index.to_gbq( | ||
destination_table, labels={"test": "labels"}, if_exists="replace" | ||
) | ||
client = scalars_df_index._session.bqclient | ||
table = client.get_table(result_table) | ||
assert table.labels | ||
assert table.labels["test"] == "labels" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("col_names", "ignore_index"), | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,7 @@ def to_gbq( | |
index: bool = True, | ||
ordering_id: Optional[str] = None, | ||
clustering_columns: Union[pd.Index, Iterable[Hashable]] = (), | ||
labels: dict[str, str] = {}, | ||
) -> str: | ||
"""Write a DataFrame to a BigQuery table. | ||
|
||
|
@@ -467,6 +468,9 @@ def to_gbq( | |
clustering order within the Index/DataFrame columns follows the order | ||
specified in `clustering_columns`. | ||
|
||
labels (dict[str, str], default None): | ||
Specifies table labels within BigQuery | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, (but since this goes in the public doc) should end with the period There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in #968! |
||
|
||
Returns: | ||
str: | ||
The fully-qualified ID for the written table, in the form | ||
|
Uh oh!
There was an error while loading. Please reload this page.