[英]Get a list of tables filtered by labels in BigQuery using Java client library
I'm using BigQuery's Java client library. 我正在使用BigQuery的Java客户端库。 May I ask if there is a way to specify labels when getting the list of BigQuery tables, so that the tables I get are already filtered by the labels I specified?
请问在获取BigQuery表列表时是否有一种方法可以指定标签,以便我获取的表已经被我指定的标签过滤了? The following example can't specify labels.
以下示例无法指定标签。
As of today, as explained in the documentation for working with BigQuery lab , this option is not possible: 截至今天,如使用BigQuery实验室的文档中所述,此选项尚不可用:
Currently, you cannot list tables or views based on a filter specification.
当前,您不能基于过滤器规范列出表或视图。
In any case, the BigQuery team is already aware that this is an interesting feature for some use cases, given that there is a public Feature Request in which this option is requested. 无论哪种情况,BigQuery团队都已经意识到,对于某些用例来说,这是一个有趣的功能,因为有一个公共功能请求 ,其中要求使用此选项。 Feel free to star it in order to receive updates, and also add a comment of your own in order to explain your use case and highlight the usability of this option.
随时给它加注星标,以接收更新,并添加您自己的评论以解释您的用例并突出此选项的可用性。
As an alternative (which may not work for you), you would still be able to list all tables in a dataset and then filter by label on the client side, although in that case the client would be retrieving all the tables, obviously. 作为替代方法(可能不适合您),您仍然可以列出数据集中的所有表 ,然后在客户端按标签进行过滤,尽管显然,在这种情况下,客户端将检索所有表。
UPDATE: 更新:
Also, I have been able to find this other public Feature Request in which the INFORMATION_SCHEMA feature is announced, also with the possibility to request access to the Alpha release of this functionality. 另外,我还可以找到该其他公共功能请求 ,其中宣布了INFORMATION_SCHEMA功能,并且还可以请求访问此功能的Alpha版本。
Your project needs to be whitelisted in order to be able to use it. 您的项目需要列入白名单才能使用。 However, once you get the access (or the public is launched into public beta / GA), you should be able to list tables using a query like:
但是,一旦获得访问权限(或将公众发布到公共beta / GA中),您应该能够使用类似以下的查询来列出表:
CREATE TABLE
[DATASET].[TABLE]
OPTIONS (labels = [('key1', 'value1'), ('key2', 'value2')])
AS SELECT 1 AS x, 'foo' AS y;
SELECT
table_name
FROM
[DATASET].INFORMATION_SCHEMA.TABLE_OPTIONS
WHERE
option_name = 'labels'
AND option_value LIKE '%key2%'
Please note that this feature is still in its Alpha release and therefore it is subject to changes in the future. 请注意,此功能仍在其Alpha版本中 ,因此将来可能会更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.