Skip to content

Commit d663104

Browse files
committed
added comment and updated to use strip instead of rstrip
1 parent 7a13ca4 commit d663104

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bigquery/google/cloud/bigquery/magics.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,16 @@ def _cell_magic(line, query):
444444
else:
445445
max_results = None
446446

447-
if not re.search(r"\s", query.rstrip()):
448-
table_id = query.rstrip()
449-
447+
query = query.strip()
448+
449+
# Any query that does not contain whitespace (aside from leading and trailing whitespace)
450+
# is assumed to be a table id
451+
if not re.search(r"\s", query):
450452
try:
451-
rows = client.list_rows(table_id, max_results=max_results)
453+
rows = client.list_rows(query, max_results=max_results)
452454
except Exception as ex:
453-
return _print_error(str(ex), args.destination_var)
455+
_print_error(str(ex), args.destination_var)
456+
return
454457

455458
result = rows.to_dataframe(bqstorage_client=bqstorage_client)
456459
if args.destination_var:

0 commit comments

Comments
 (0)