指定实体
In the snowflake.yml definition file, you can specify multiple entities. Each entity is identified by a unique key. The example below specifies two entities with the entity_a and entity_b keys:
每个实体都必须指定一个类型。目前支持的类型包括:
实体标识符
You can specify multiple entities of the same type in the snowflake.yml file. You can name entities in the following ways:
-
在实体列表中使用唯一密钥。
The following example shows using
entity_aandentity_bas the unique keys: -
Specify an
identifiername to each entity.The following example adds identifier names to the
entity_aandentity_bentities: -
Add an
identifierobject to each entity.
使用标识符对象允许为每个实体指定名称、数据库和架构,如以下示例所示:
如果未指定标识符,则使用实体密钥作为对象的名称,而不需要任何数据库或架构限定。
项目 mixin¶
In many cases you might find it useful to define project-wide default values. Mixins provide a way to extract common attributes out of individual entities. You can specify multiple mixins. You need to declare which mixins should be used by each entity using meta.use_mixins property.
在实体中使用 mixin 时,必须确保 mixin 的所有属性都可以应用于该实体。应用实体上不可用的属性会导致错误。因此,在某些情况下,您可能需要使用多个 mixin。
Note
显式声明的实体属性可覆盖 Mixin 值。
The following example includes two mixins: stage_mixin and snowpark_shared. The my_dashboard entity uses only stage_mixin, while the my_function entity uses both of the mixins.
If an entity uses multiple mixins that specify the same property, the entity uses the value of later mixin. In the following example, the value of key on the foo entity will be mixin_2_value.
应用 mixin 值的行为取决于值类型。对于标量值(字符串、数字、布尔),值将被覆盖。
| Mixin notation | Explicit result |
|---|---|
如果是序列,则合并值以创建新序列。此实施可避免在序列中创建重复条目。
| Mixin notation | Explicit result |
|---|---|
对于映射值,将添加新键并更新现有值。更新具有递归性。
| Mixin notation | Explicit result |
|---|---|