简体   繁体   English

BigQuery 中的“path_expression”是什么

[英]What is a "path_expression" in BigQuery

BigQuery describes a path_expression in the Syntax page as follows: BigQuery 在语法页面中描述了一个path_expression ,如下所示:

A path expression describes how to navigate to an object in a graph of objects and generally follows this structure...路径表达式描述了如何在对象图中导航到 object,并且通常遵循此结构...

Examples:例子:

 foo.bar foo.bar/25 foo/bar:25 foo/bar/25-31 /foo/bar /25/foo/bar

What are some actual examples of a Path Expression with a valid table, for example in a CTE?具有有效表的路径表达式的一些实际示例是什么,例如在 CTE 中? My thinking was that a path expression would be something that explicitly qualifies a field or struct sub-field, such as:我的想法是路径表达式将是明确限定字段或结构子字段的内容,例如:

myTable.myField.mySubfield

But from the above syntax, which allows for:但是从上面的语法来看,它允许:

/:-

I'm not exactly sure what it is or how it would be used.我不确定它是什么或如何使用它。 Could someone show a real-world example of how a path expression would be used?有人可以展示一个如何使用路径表达式的真实示例吗?

Path expressions describe where to search for (or store) data.路径表达式描述了在哪里搜索(或存储)数据。 Consider this example :考虑这个例子

#legacySQL
SELECT
  weight_pounds, state, year, gestation_weeks
FROM
  [bigquery-public-data:samples.natality]
ORDER BY
  weight_pounds DESC
LIMIT
  10;

In this example, the portion [bigquery-public-data:samples.natality] is the path_expression .在此示例中,部分[bigquery-public-data:samples.natality]path_expression It is saying to look at the natality table in the samples database in the bigquery-public-data project.据说要查看natality bigquery-public-data项目中samples数据库中的出生表。

But from the above syntax, which allows for: /:-但是从上面的语法来看,它允许: /:-

This would actually not be allowed, as a path_expression .这实际上是不允许的,作为path_expression

This example would be parsed as:此示例将被解析为:

/:-

{first_part}/{subsequent_part}:{subsequent_part}

{{ unquoted_identifier | quoted_identifier }} / 
{{ unquoted_identifier | quoted_identifier | number }} : 
{{ unquoted_identifier | quoted_identifier | number }}

An unquoted_identifier must at least begin with a letter or an underscore. unquoted_identifier必须至少以字母或下划线开头。 A quoted_identifier can contain any character, but cannot be empty.一个quoted_identifier可以包含任何字符,但不能为空。 The empty string therefore cannot be considered an unquoted_identifier , quoted_identifier , or number , so this expression is invalid (and is invalid in 3 positions).因此,空字符串不能被视为unquoted_identifierquoted_identifiernumber ,因此该表达式无效(并且在 3 个位置无效)。

A possible minimal path_expression could be something like:一个可能的最小path_expression可能类似于:

a:b.c

meaning look in the c table in the b database in the a project.意思是在a项目的b数据库中查看c表。

I can be wrong, but I think you are confusing Path Expression (as it is defined in referenced documentation) with something like (for example) JSONPath.我可能是错的,但我认为您将Path Expression (如参考文档中定义的那样)与(例如)JSONPath 之类的东西混淆了。
In my mind, the the former is just terminology that introduced in order to have consistent reference within the documentation, while later (obviously) is query language for JSON, similar to XPath for XML, etc.在我看来,前者只是为了在文档中有一致的参考而引入的术语,而后来(显然)是 JSON 的查询语言,类似于 Z3501BB093D363810B671EDF8Z9 的 XPath 的查询语言。

So, if you would asked for something like JSONPath use - I bet you would get tones of usage examples, but asking about Path Expression use has not much chances to gather answers even having hefty bounty as it is ONLY used in that documentation因此,如果您要求使用 JSONPath 之类的东西 - 我敢打赌您会得到一些使用示例,但询问Path Expression use并没有太多机会收集答案,即使有大量的赏金,因为它仅在该文档中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM