- Notifications
You must be signed in to change notification settings - Fork1.6k
Closed
Description
Is your feature request related to a problem? Please describe.
Currently aTableListItem can't be supplied to theTable constructor
In [1]:fromgoogle.cloudimportbigqueryIn [2]:c=bigquery.Client()/usr/local/lib/python3.6/site-packages/google/auth/_default.py:66:UserWarning:YourapplicationhasauthenticatedusingendusercredentialsfromGoogleCloudSDK.Werecommendthatmostserverapplicationsuseserviceaccountsinstead.IfyourapplicationcontinuestouseendusercredentialsfromCloudSDK,youmightreceivea"quota exceeded"or"API not enabled"error.Formoreinformationaboutserviceaccounts,seehttps://cloud.google.com/docs/authentication/warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)/usr/local/lib/python3.6/site-packages/google/auth/_default.py:66:UserWarning:YourapplicationhasauthenticatedusingendusercredentialsfromGoogleCloudSDK.Werecommendthatmostserverapplicationsuseserviceaccountsinstead.IfyourapplicationcontinuestouseendusercredentialsfromCloudSDK,youmightreceivea"quota exceeded"or"API not enabled"error.Formoreinformationaboutserviceaccounts,seehttps://cloud.google.com/docs/authentication/warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)In [3]:c.list_tables('sixty')Out[3]:<google.api_core.page_iterator.HTTPIteratorat0x7fb5ac642e48>In [4]:tables=list(c.list_tables('sixty'))In [5]:tablesOut[5]:[<google.cloud.bigquery.table.TableListItemat0x7fb5ae747048>,<google.cloud.bigquery.table.TableListItemat0x7fb5ae747240>,<google.cloud.bigquery.table.TableListItemat0x7fb5ae7470f0>,<google.cloud.bigquery.table.TableListItemat0x7fb5ae7477f0>,<google.cloud.bigquery.table.TableListItemat0x7fb5ae747e80>,<google.cloud.bigquery.table.TableListItemat0x7fb5ae747c88>,<google.cloud.bigquery.table.TableListItemat0x7fb554282710>]In [6]:c.get_table(tables[0])Out[6]:Table(TableReference(DatasetReference('sixty-capital','sixty'),'equities'))In [7]:bigquery.Table(tables[0])---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)<ipython-input-7-ac46513e6958>in<module>---->1bigquery.Table(tables[0])/usr/local/lib/python3.6/site-packages/google/cloud/bigquery/table.pyin__init__(self,table_ref,schema)365ifisinstance(table_ref,six.string_types):366table_ref=TableReference.from_string(table_ref)-->367self._properties= {"tableReference":table_ref.to_api_repr(),"labels": {}}368# Let the @property do validation.369ifschemaisnotNone:AttributeError:'TableListItem'objecthasnoattribute'to_api_repr'
Describe the solution you'd like
Table can take a reference, a string, aTableListItem, anything that could be a Table - overall either unify the types or make conversions between them implicit
The python BigQuery API has got waaay better, but I still find myself looking at the API docs most times I use it, and it still sometimes feels tethered to the HTTP API (or distant memories of writing Java code :) )
Thank you!