[英]python bigquery get external table meta data
I want to get the external meta data of a table created in bigquery. 我想获取在bigquery中创建的表的外部元数据。 The table was created like this:
该表是这样创建的:
table_ref = self._client.dataset('test').table('test')
table = bigquery.Table(table_ref)
self._extconfig = bigquery.ExternalConfig('AVRO')
self._extconfig.autodetect = True
self._extconfig.source_uris = ['gs://someproject/bucket/dir/file*.avro']
table.external_data_configuration = self._extconfig
self._client.create_table(table)
Now i want to access the meta data stored in external_data_configuration'
like this: 现在我想像这样访问存储在
external_data_configuration'
的元数据:
dataset = self._client.dataset('test')
table_ref = dataset.table('test')
table = bigquery.Table(table_ref)
print(table.table_id)
print(table.path)
print(table.table_type)
print(table.external_data_configuration)
But all i receive is None for table_type, where i would expect 'AVRO' and also None for external_data_configuration. 但是我所收到的只是table_type的None,我期望的是“ AVRO”,而external_data_configuration的None。
Is there a way to get the external_data_configuration, especially the source_uris
for external tables? 有没有一种方法可以获取external_data_configuration,尤其是外部表的
source_uris
?
Try this instead: 尝试以下方法:
dataset = self._client.dataset('test')
table_ref = dataset.table('test')
table = self._client.get_table(table_ref)
print(table.external_data_configuration.source_uris)
The get_table
will fetch all the information of the table into the table
variable. get_table
会将表的所有信息提取到table
变量中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.