Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit20f473b

Browse files
fix: make TimePartitioning repr evaluable (#110)
Fixes#109 🦕
1 parent5ea1ece commit20f473b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎google/cloud/bigquery/table.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,20 @@ def to_api_repr(self):
21142114
returnself._properties
21152115

21162116
def_key(self):
2117-
returntuple(sorted(self._properties.items()))
2117+
# because we are only "renaming" top level keys shallow copy is sufficient here.
2118+
properties=self._properties.copy()
2119+
# calling repr for non built-in type objects.
2120+
properties["type_"]=repr(properties.pop("type"))
2121+
if"field"inproperties:
2122+
# calling repr for non built-in type objects.
2123+
properties["field"]=repr(properties["field"])
2124+
if"requirePartitionFilter"inproperties:
2125+
properties["require_partition_filter"]=properties.pop(
2126+
"requirePartitionFilter"
2127+
)
2128+
if"expirationMs"inproperties:
2129+
properties["expiration_ms"]=properties.pop("expirationMs")
2130+
returntuple(sorted(properties.items()))
21182131

21192132
def__eq__(self,other):
21202133
ifnotisinstance(other,TimePartitioning):

‎tests/unit/test_table.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3711,7 +3711,7 @@ def test___hash__not_equals(self):
37113711

37123712
deftest___repr___minimal(self):
37133713
time_partitioning=self._make_one()
3714-
expected="TimePartitioning(type=DAY)"
3714+
expected="TimePartitioning(type_='DAY')"
37153715
self.assertEqual(repr(time_partitioning),expected)
37163716

37173717
deftest___repr___explicit(self):
@@ -3720,7 +3720,7 @@ def test___repr___explicit(self):
37203720
time_partitioning=self._make_one(
37213721
type_=TimePartitioningType.DAY,field="name",expiration_ms=10000
37223722
)
3723-
expected="TimePartitioning(""expirationMs=10000,""field=name,""type=DAY)"
3723+
expected="TimePartitioning(expiration_ms=10000,field='name',type_='DAY')"
37243724
self.assertEqual(repr(time_partitioning),expected)
37253725

37263726
deftest_set_expiration_w_none(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp