Skip to content

Commit a6631e1

Browse files
Refactor
1 parent 75e6b6b commit a6631e1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pybigquery/sqlalchemy_bigquery.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,20 @@ def _split_table_name(full_table_name):
369369
def _table_reference(self, provided_schema_name, provided_table_name,
370370
client_project):
371371
project_id_from_table, dataset_id_from_table, table_id = self._split_table_name(provided_table_name)
372-
if project_id_from_table:
373-
project_id = project_id_from_table
374-
elif dataset_id_from_table:
375-
project_id = provided_schema_name or client_project
376-
else:
377-
project_id = client_project
372+
project_id_from_schema = None
373+
if provided_schema_name is not None:
374+
provided_schema_name_split = provided_schema_name.split('.')
375+
if len(provided_schema_name_split) == 0:
376+
pass
377+
elif len(provided_schema_name_split) == 1:
378+
if dataset_id_from_table:
379+
project_id_from_schema = provided_schema_name_split[0]
380+
else:
381+
pass # TODO: write a test case
382+
elif len(provided_schema_name_split) == 2:
383+
pass
384+
# TODO: Get a test for an else statement here
385+
project_id = project_id_from_schema or project_id_from_table or client_project
378386
dataset_id = dataset_id_from_table or provided_schema_name or self.dataset_id
379387

380388
table_ref = TableReference.from_string("{}.{}.{}".format(

0 commit comments

Comments
 (0)