实体名称Entity names

Kusto 实体(数据库、表、列和存储函数;群集是例外)具有名称。Kusto entities (databases, tables, columns, and stored functions; clusters are an exception) are named. 实体的名称标识实体,并且(在给定其类型的情况下)在其容器作用域内必定是唯一的。The name of an entity identifies the entity, and is guaranteed to be unique in the scope of its container given its type. (例如,同一数据库中的两个表不能同名,但表和数据库可以同名,因为它们不在同一作用域内;表和存储函数的名称也可以相同,因为它们不是同一实体类型。)(So, for example, two tables in the same database can't have the same name, but a table and a database may have the same name because they are not in the same scope, and a table and a stored function may have the same name because they are not of the same entity type.)

出于解析目的,实体名称区分大小写(因此不能将名为 ThisTable 的表称为 thisTABLE)。Entity names are case-sensitive for resolving purposes (so, for example, you can't refer to a table called ThisTable as thisTABLE).

实体名称是标识符的一个示例。Entity names are one example of identifiers. 其他标识符包括函数参数的名称,以及通过 let 语句绑定名称。Other identifiers include the names of parameters to functions and binding a name through a let statement.

实体友好名称Entity pretty names

除实体名称外,某些实体(如数据库)还可能具有友好名称。Some entities (such as databases) may have, in addition to their entity name, a pretty name. 可以在查询中使用友好名称来指代实体(类似实体名称),但与实体名称不同的是,在其容器的上下文中,友好名称不一定是唯一的。Pretty names can be used to reference the entity in queries (like entity names), but, unlike entity names, pretty names aren't necessarily unique in the context of their container. 如果容器包含多个具有相同友好名称的实体,则不能使用该友好名称来指代实体。When a container has multiple entities with the same pretty name, the pretty name can't be used to reference the entity.

友好名称允许中间层应用程序将自动创建的实体名称(如 UUID)映射到易于理解的名称,以便显示和引用。Pretty names allow middle-tier applications to map automatically-create entity names (such as UUIDs) to names that are human-readable for display and referencing purposes.

标识符命名规则Identifier naming rules

标识符用于命名各种实体(实体或其他项)。Identifiers are used to name various entities (entities or otherwise). 有效的标识符名称遵循以下规则:Valid identifier names follow these rules:

  • 长度必须介于 1 到 1024 个字符之间。They have between 1 and 1024 characters long.
  • 可以包含字母、数字、下划线 (_)、空格、点 (.) 和短划线 (-)。They may contain letters, digits, underscores (_), spaces, dots (.), and dashes (-).
    • 引用标识符时,仅由字母、数字和下划线组成的标识符不需要加引号。Identifiers consisting only of letters, digits, and underscores do not require quoting when the identifier is being referenced.
    • 包含空格、点或短划线中至少一种符号的标识符需要加引号(见下文)。Identifiers containing at last one of (spaces, dots, or dashes) do require quoting (see below).
  • 它们区分大小写。They are case-sensitive.

标识符引用Identifier quoting

如果标识符与某些查询语言关键字相同,或者包含上述某个特殊字符,则由查询直接引用这些标识符时需要加引号:Identifiers that are identical to some query language keywords, or have one of the special characters noted above, require quoting when they are referenced directly by a query:

查询文本Query text 注释Comments
entity 不包含特殊字符或映射到某些语言关键字的实体名称 (entity) 不需要加引号Entity names (entity) that do not include special characters or map to some language keyword require no quoting
['entity-name'] 包含特殊字符(此处为:-)的实体名称必须使用 [''] 或者 [""] 括起来Entity names that include special characters (here: -) must be quoted using [' and '] or using [" and "]
["where"] 作为语言关键字的实体名称必须用 [''] 或者 [""] 括起来Entity names that are language keywords must be quoted quoted using [' and '] or using [" and "]

命名实体以避免与 Kusto 语言关键字冲突Naming your entities to avoid collisions with Kusto language keywords

由于 Kusto 查询语言包含多个关键字,而这些关键字具有与标识符相同的命名规则,因此,可能出现与关键字重合的实体名称,但引用这些名称会很困难(必须加引号)。As the Kusto query language includes a number of keywords that have the same naming rules as identifiers, it is possible to have entity names that are actually keywords, but then referring to these names becomes difficult (one must quote them).

或者,最好选择绝对不会与 Kusto 关键字“冲突”的实体名称。Alternatively, one might want to choose entity names that are guaranteed to never "collide" with a Kusto keyword. 该语言有以下保证:The following guarantees are made:

  1. Kusto 查询语言不会定义以大写字母(AZ)开头的关键字。The Kusto query language will not define a keyword that starts with a capital letter (A to Z).
  2. Kusto 查询语言不会定义以单下划线 (_) 开头的关键字。The Kusto query language will not define a keyword that starts with a single underscore (_).us
  3. Kusto 查询语言不会定义以单下划线 (_) 结尾的关键字。The Kusto query language will not define a keyword that ends with a single underscore (_).

Kusto 查询语言保留以双下划线字符序列 (__) 开头或结尾的所有标识符;用户不能定义这样的名称供自己使用。The Kusto query language reserves all identifiers that start or end with a sequence of two underscore characters (__); users cannot define such names for their own use.