Limit | Description |
Creation Permission | Creating a metric requires the CreateMetric or Manage permission on the model; creating a metric does not require the Select permission on the underlying table |
Editing Mode | Metrics and dimensions are both edited through the YAML editor. |
Dimension ACL | Dimensions do not support fine-grained ACL permissions in this release. All users with Read Write or Read Write & Delete feature permissions on "Semantic Modeling → Dimension Management" can edit and delete dimensions. |
SUM(OrderAmount) represents the total transaction amount. Atomic metrics do not involve derived logic.SUM(OrderAmount) with the filter Channel = Online.Total Transaction Amount / Number of Transactions.Number of Orders / Number of Registrations.SUM, COUNT, COUNT(DISTINCT), MAX, MIN, AVG, and custom expressions.formula field in a derived metric YAML must be metrics that are already published under the same model or defined simultaneously in the same YAML. Otherwise, validation fails during publishing.SIMPLE / FILTER / DERIVED / RATIO / CUMULATIVE / CONVERSION), and three dimension types (TIME / CATEGORICAL / DICT) in a single declaration. You can use it as a reference template when writing actual YAML files.# ============================================================# Complete Example of WeData Semantic Model YAML Configuration# Version: 1.0# Note: This YAML allows you to create semantic models, metrics, and dimensions all at once.# ============================================================# [Required] Configuration file version, fixed at 1.0.version: 1.0# ============================================================# Semantic Model Definition (Optional)# type: DEF - Create a model (a complete definition is required).# REF - Reference an existing model (only name + type required).# ============================================================model:# [Required] Model name in English, 1-50 characters, supporting letters, digits, underscores, and parentheses.name: ecommerce_order_model# [Optional] List of model aliases. Multiple aliases are supported, and commas are not allowed.# Defaults to name when empty. Stored as comma-separated values in the database.label:- E-commerce order model- order_model_alias# [Optional] Model descriptiondescription: "The primary e-commerce order model, associated with the user table and the product table."# [Required] Model type: DEF (define a new model) | REF (reference an existing model).type: DEF# [Required for DEF] Path to the primary table data source. Format: catalogName.databaseName.tableName.source: default_catalog.ecommerce_db.orders# [Optional] JOIN table configuration. Nested JOINs are supported.joins:- name: user_table # Alias of the joined table (required)source: default_catalog.ecommerce_db.users # Path of the joined table (required)on: # Join condition (required, at least one)- source.user_id = user_table.id# Nested joins (optional)joins:- name: user_addresssource: default_catalog.ecommerce_db.addresseson:- user_table.id = user_address.user_id- name: product_tablesource: default_catalog.ecommerce_db.productson:- source.product_id = product_table.id# ============================================================# Metric definition list (optional)# Supported types: SIMPLE | FILTER | DERIVED | RATIO | CUMULATIVE | CONVERSION# ============================================================metrics:# ----------------------------------------------------------# 1. Atomic metric (SIMPLE) - Basic aggregate metric# ----------------------------------------------------------- name: total_order_amount# [Optional] Metric alias list. Chinese characters, English letters, digits, underscores, and parentheses are supported. Commas are not allowed.label:- Total order amount- GMVdescription: "Calculates the total amount of all valid orders."# [Required] Metric typetype: SIMPLE# [Required] Type parametertype_params:# [Optional] Referenced model. Specify the model name.# If not specified, the model defined in the current YAML is used by default.model_ref: ecommerce_order_model# [Required] Source table path. Format: catalogName.databaseName.tableNamesource_table: default_catalog.ecommerce_db.orders# [Required] Aggregate expressionexpr: "SUM(order_amount)"# [Required] Time dimension name. You must define the corresponding TIME dimension in dimensions.time_dimension: order_date# [Optional] Non-additive dimension configuration. Use this for semi-additive metrics, such as inventory snapshots.# non_additive_dimension:# dimension: snapshot_date # Dimension name (required)# window_choice: MAX # Window value: MIN | MAX (required)# window_groupings: # Window groupings (optional)# - warehouse_id# ----------------------------------------------------------# 2. Filter metric (FILTER) - Adds filter conditions to an atomic metric.# ----------------------------------------------------------- name: paid_order_amountlabel:- Paid order amountdescription: "Calculates the total amount of orders in paid status only."type: FILTERtype_params:# [Required] Filter condition expressionfilter: "status = 'PAID'"# [Required] List of dependent base metrics (at least one)metrics:- name: total_order_amount# ----------------------------------------------------------# 3. Hybrid calculated metric (DERIVED) - Multi-metric expression calculation.# ----------------------------------------------------------- name: avg_order_amountlabel:- Average order value per customerdescription: "Total order amount / Total number of orders"type: DERIVEDtype_params:# [Required] Calculation expression. Use metric names as variables.expr: "total_order_amount / order_count"# [Required] List of base metrics involved in the calculation (at least one)metrics:- name: total_order_amount- name: order_count# ----------------------------------------------------------# 4. Period-over-period metric (RATIO) - Time period comparison.# ----------------------------------------------------------- name: order_amount_yoylabel:- Year-over-year order amountdescription: "Year-over-year growth rate of total order amount"type: RATIOtype_params:# [Required] Calculation type: YEAR_ON_YEAR (year-over-year) | RELATIVE_RATIO (period-over-period)derived_type: YEAR_ON_YEAR# [Required] List of base metrics (at least one)metrics:- name: total_order_amount# ----------------------------------------------------------# 5. Cumulative metric (CUMULATIVE) - Time window accumulation.# ----------------------------------------------------------- name: weekly_order_amountlabel:- Order amount for the last 7 daysdescription: "Cumulative order amount for the last 7 days"type: CUMULATIVEtype_params:# [Required] Time window. Valid values:# MINUTE_5 | MINUTE_30 | HOUR_1 | DAY_1 | DAY_7 | DAY_30 | DAY_90 | DAY_180# WTD (week-to-date) | MTD (month-to-date) | QTD (quarter-to-date) | YTD (year-to-date) | HTD (history-to-date)window: DAY_7# [Optional] Additional filter conditionsfilter: "status IN ('PAID', 'SHIPPED')"# [Required] List of base metrics (at least one)metrics:- name: total_order_amount# ----------------------------------------------------------# 6. Conversion metric (CONVERSION) - Funnel conversion analysis.# ----------------------------------------------------------- name: view_to_purchase_ratelabel:- Browse-to-purchase conversion ratedescription: "Conversion rate from product browsing to purchase"type: CONVERSIONtype_params:# [Required] Base metric (funnel starting point)base_metric:name: page_view_count# [Required] Conversion metric (funnel endpoint)conversion_metric:name: purchase_count# [Required] Conversion entity type: FROM_ENTITY | FROM_DIMENSIONconversion_entity_type: FROM_DIMENSION# [Optional] Conversion dimension (used when conversion_entity_type is FROM_DIMENSION)conversion_dimension: user_id# [Required] Calculation method: CONVERSIONS (conversion value) | CONVERSIONRATE (conversion rate)calculation: CONVERSIONRATE# [Optional] Window type: WINDOW (conversion within N time) | OFFSET (conversion at the Nth time)window_type: WINDOW# [Optional] Time window. Format: {number} {hour|day|week|month}window: "7 day"# ----------------------------------------------------------# 7. Conversion metric (CONVERSION) - FROM_ENTITY example# Associate base metrics with conversion metrics through entities (primary keys/associated keys).# ----------------------------------------------------------- name: register_to_order_conversionslabel:- Signup-to-order conversionsdescription: "Number of conversions from registration to first order, associated through the user entity."type: CONVERSIONtype_params:# [Required] Base metric (funnel starting point)base_metric:name: user_register_count# [Required] Conversion metric (funnel endpoint)conversion_metric:name: total_order_amount# [Required] Conversion entity type: FROM_ENTITY indicates that two metrics are associated through an entity (primary key).# FROM_ENTITY: Two metrics are automatically associated through the same entity (such as user ID), so there is no need to specify conversion_dimension.# FROM_DIMENSION: You need to manually specify the conversion_dimension field to associate the metrics.conversion_entity_type: FROM_ENTITY# [Required] Calculation method: CONVERSIONS (number of conversions) | CONVERSIONRATE (conversion rate)calculation: CONVERSIONS# [Optional] Window type: WINDOW (conversion within N time) | OFFSET (conversion at the Nth time)window_type: OFFSET# [Optional] Time window. Format: {number} {hour|day|week|month}window: "30 day"# ============================================================# Dimension definition list (optional)# Supported types: TIME | CATEGORICAL | DICT# ============================================================dimensions:# ----------------------------------------------------------# 1. Time dimension (TIME) - You must specify the time precision.# ----------------------------------------------------------- name: order_date# [Optional] List of dimension aliases. Multiple aliases are supported, and commas are not allowed.label:- Order date- Order timedescription: "Order creation time, accurate to the day"# [Required] Data source path. Format: catalogName.databaseName.tableNamesource: default_catalog.ecommerce_db.orders# [Required] Corresponding database column namecol_name: created_time# [Required] Dimension typetype: TIME# [Required for TIME type] Type parametertype_param:# Time precision. Valid values: YEAR | MONTH | DAY | HOUR | MINUTE | SECOND | MILLISECOND.time_precision: DAY# ----------------------------------------------------------# 2. Generic dimension (CATEGORICAL)# ----------------------------------------------------------- name: order_channellabel:- Order channeldescription: "Order source channel: APP/PC/H5"source: default_catalog.ecommerce_db.orderscol_name: channeltype: CATEGORICAL# The CATEGORICAL type does not require type_param. Leave it empty.# ----------------------------------------------------------# 3. Dictionary dimension (DICT) - Associated dictionary table# ----------------------------------------------------------- name: order_statuslabel:- Order statusdescription: "Order status code, associated with a dictionary table"source: default_catalog.ecommerce_db.orderscol_name: status_codetype: DICT# [Required for DICT type] Type parametertype_param:dict_items:- key: Shippedvalue: Shipped- key: Completedvalue: Completed- key: Canceledvalue: Canceled
version: 1.0 is the configuration file version, fixed at 1.0.model.type = DEF, provide the complete model definition (source + joins). When it is changed to REF, only name + type are required, indicating a reference to an existing model.type_params structures of the six metric types vary:SIMPLE is defined by expr (aggregate expression) + time_dimension;FILTER adds filter conditions to the atomic metrics referenced by metrics;DERIVED uses expr to reference other metric names for arithmetic operations;RATIO uses derived_type (YEAR_ON_YEAR / RELATIVE_RATIO) to declare year-over-year or period-over-period comparison;CUMULATIVE uses window (such as DAY_7 / MTD) to declare time window accumulation;CONVERSION declares funnel conversion through base_metric / conversion_metric / conversion_entity_type / calculation / window.type_param structures of the three dimension types:TIME requires time_precision (such as DAY / HOUR / MONTH);CATEGORICAL has no type_param;DICT declares key-value mappings through dict_items.name in the model YAML to avoid duplicate declarations.order_date (order creation date) and pay_time (payment completion time), which are often sliced by day, week, or month.category_name (product category), brand (brand), and gender (gender).user_name (user name), age (age), and user_id (user ID).A / B) or a text description. Different calculation logic information is displayed for each metric type based on its type.select * from query(metric=[avg_session_behavior_count], limit=30)
Upstream: Tables and views (2) Semantic models (1) Upstream: Metrics (2) Current metric┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────┐│ Order fact table │─>│ Customer │─>│ metric.Session count │─>│ avg_se││ ODS data table │ │ Behavior │ │ metric.Behavior count │ │ count │└──────────────┘ └──────────────┘ └──────────────┘ └──────────┘
Field | Required | Description |
Authorization subject | Yes | User, user group, or tag can be selected. |
Authorized object | Yes | If User is selected as the authorization principal: a user selection panel is displayed, and user search is supported; add at least one user. If User Group is selected as the authorization principal: a user group selection panel is displayed, and user group search is supported; add at least one user group. If Tag is selected as the authorization principal: no authorization object needs to be selected; only select the authorization point below. |
Permission point | Yes | Select at least one item; if none is selected, the submit button is grayed out and a message prompts "Please select a permission point." You can set row and column permissions for metrics that the authorization object can query. |
Authorization reason | No | Multiline text for audit and business context description. |
User input |
In my olist_sales_model semantic model, add a gmv metric. The calculation logic is to sum the pay_amount field in the dlc.default_catalog.olist.orders table to calculate the total payment amount of all orders (total transaction value). Note that during calculation, exclude data from orders placed by internal customers (customer type is "internal"). |
User input |
Create a "payment time" dimension with table name dlc.default_catalog.olist.orders, field name pay_time, minimum time granularity by DAY, indicating the actual time when an order payment is completed. |
catalog.database.table, for example, dlc.default_catalog.olist.orders.CreateMetric permission on the target model. If not, the creation is denied.formula of a derived metric reference metrics from other models?
No. A derived metric can only reference metrics under the same model.COUNT(DISTINCT) is not directly supported by some engines, so you need to confirm the deduplication syntax supported by the platform. ③ A function name in the custom SQL is not recognized by the engine. We recommend that you first verify that the expression can be executed by using the underlying table in the SQL editor before publishing.フィードバック