Skip to content

Commit b66d852

Browse files
author
Matti Remes
committed
Add exists check for dpt table
1 parent ea16285 commit b66d852

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pandas_gbq/gbq.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,9 @@ class _Table(GbqConnector):
10101010

10111011
partition_decorator = '$'
10121012

1013+
def _is_date_partitioned_table(self, table_id):
1014+
return self.partition_decorator in table_id
1015+
10131016
def __init__(self, project_id, dataset_id, reauth=False, verbose=False,
10141017
private_key=None):
10151018
self.dataset_id = dataset_id
@@ -1031,8 +1034,12 @@ def exists(self, table_id):
10311034
from google.api_core.exceptions import NotFound
10321035

10331036
table_ref = self.client.dataset(self.dataset_id).table(table_id)
1037+
10341038
try:
1035-
self.client.get_table(table_ref)
1039+
table = self.client.get_table(table_ref)
1040+
if self._is_date_partitioned_table(table_id):
1041+
return table.num_rows > 0
1042+
10361043
return True
10371044
except NotFound:
10381045
return False

0 commit comments

Comments
 (0)