Skip to content

Commit

Permalink
added comment and updated to use strip instead of rstrip
Browse files Browse the repository at this point in the history
  • Loading branch information
shubha-rajan committed Sep 21, 2019
1 parent 7a13ca4 commit d663104
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bigquery/google/cloud/bigquery/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,16 @@ def _cell_magic(line, query):
else:
max_results = None

if not re.search(r"\s", query.rstrip()):
table_id = query.rstrip()

query = query.strip()

# Any query that does not contain whitespace (aside from leading and trailing whitespace)
# is assumed to be a table id
if not re.search(r"\s", query):
try:
rows = client.list_rows(table_id, max_results=max_results)
rows = client.list_rows(query, max_results=max_results)
except Exception as ex:
return _print_error(str(ex), args.destination_var)
_print_error(str(ex), args.destination_var)
return

result = rows.to_dataframe(bqstorage_client=bqstorage_client)
if args.destination_var:
Expand Down

0 comments on commit d663104

Please sign in to comment.