### HTTP GET Request Example Source: https://docs.can.aloudata.com/API-%E6%A0%B9%E6%8D%AEID%E6%9F%A5%E8%AF%A2%E6%8C%87%E6%A0%87%E8%A7%86%E5%9B%BE%E8%AF%A6%E6%83%85 An example of an HTTP GET request to query metric view details by ID. This demonstrates the basic structure of the request URL, including the base path and the required 'id' query parameter. ```http GET http://127.0.0.1/anymetrics/api/v1/analysisview/query?id=1 ``` -------------------------------- ### MinBy Example: Lowest Priced Product Source: https://docs.can.aloudata.com/MinBy Example demonstrating how to use MinBy to find the ProductName of the product with the lowest price, based on the Price field. ```plaintext MinBy(ProductName, Price) ``` -------------------------------- ### Response Example - Token Creation Success Source: https://docs.can.aloudata.com/API-%E8%8E%B7%E5%8F%96%E8%AE%BF%E9%97%AE%E5%87%AD%E8%AF%81 Example of a successful response when creating an access token from the Aloudata CAN metrics platform. It includes the generated token, success status, response code, and trace ID. ```json { "data": "93dd39196fcf9732", "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "2bc7df9f294144deab6535e0b2a9b546.156.17234653117621755" } ``` -------------------------------- ### Variance Function Syntax and Result Example Source: https://docs.can.aloudata.com/Variance Illustrates the basic syntax of the Variance function and shows an example of its application with a specific dataset, including the expected output. This helps in understanding the function's direct application and result format. ```data-analysis Variance(<数据内容>) Variance(QuarterlySales) = 1250000 ``` -------------------------------- ### MinBy Example: Earliest Customer Source: https://docs.can.aloudata.com/MinBy Example demonstrating how to use MinBy to find the CustomerID of the customer who placed the earliest order, based on the OrderDate. ```plaintext MinBy(CustomerID, OrderDate) ``` -------------------------------- ### First Function Example: Get First Order Date Source: https://docs.can.aloudata.com/First This example demonstrates how to use the First function to retrieve the first order date from an 'OrderDate' field in a table. It requires a field containing date information. ```plaintext First(OrderDate) ``` -------------------------------- ### Metrics Query API Request Example (JSON) Source: https://docs.can.aloudata.com/API-%E6%8C%87%E6%A0%87%E6%95%B0%E6%8D%AE%E6%9F%A5%E8%AF%A2 Example of a POST request body for the Metrics Query API. It demonstrates how to specify metrics, define temporary metrics, list dimensions, set time constraints, and control the query result type. ```json { "metrics": [ "orderCount", "orderCount_total" ], "metricDefinitions":{ "orderCount_total":{ "refMetric":"orderCount", "specifyDimension":{ "type":"INCLUDE", "dimensions":"metric_time__day,province" } } }, "dimensions": [ "metric_time__day", "province", "city" ], "filters": [], "timeConstraint": "([metric_time__month]= DateTrunc(Today(),"MONTH"))", "limit": 30, "offset": 1, "queryResultType":"SQL_AND_DATA" } ``` -------------------------------- ### GET /anymetrics/api/v1/lineage/queryAll Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E7%9C%8B%E6%89%80%E6%9C%89%E8%A1%80%E7%BC%98 本接口用于获取指定资产的上下游血缘关系。 ```APIDOC ## GET /anymetrics/api/v1/lineage/queryAll ### Description 本接口用于获取指定资产的上下游血缘关系。 ### Method GET ### Endpoint `http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/lineage/queryAll` ### Parameters #### Path Parameters - **anymetrics_host** (string) - Required - Anymetrics host. - **anymetrics_port** (string) - Required - Anymetrics port. #### Query Parameters - **tenant-id** (String) - Required - `租户ID`,用于指标查询内容所在的租户 - **auth-type** (String) - Required - 认证方式支持: `UID`(基于用户ID认证) `TOKEN`(基于令牌认证)。 - **auth-value** (String) - Required - 与选定的`auth-type`相对应的认证值。 ### Request Example ``` http://127.0.0.1:8083/anymetrics/api/v1/lineage/queryAll ``` ### Response #### Success Response (200) - **srcVertex** (string) - 起始点 - **srcVertexType** (string) - 起始点类型 - **dstVertex** (string) - 目标点 - **dstVertexType** (string) - 目标点类型 #### Response Example ```json { "srcVertex": "aloudata_am_upload_database_dev.public.product", "srcVertexType": "FILE", "dstVertex": "tb_product", "dstVertexType": "DATASET" } ``` ``` -------------------------------- ### GET /anymetrics/api/v1/analysisview/list Source: https://docs.can.aloudata.com/API-%E6%8C%87%E6%A0%87%E8%A7%86%E5%9B%BE%E5%88%97%E8%A1%A8 本接口用于实现依据关键词对指标视图列表进行模糊匹配搜索的功能。 ```APIDOC ## GET /anymetrics/api/v1/analysisview/list ### Description 本接口用于实现依据关键词对指标视图列表进行模糊匹配搜索的功能。 ### Method GET ### Endpoint `Http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/analysisview/list` ### Parameters #### Path Parameters - **anymetrics_host** (string) - Required - The host of the AnyMetrics service. - **anymetrics_port** (string) - Required - The port of the AnyMetrics service. #### Query Parameters - **keyword** (string) - Optional - 指标视图名称关键字,如果不传,则查询所有的. Max length: 32. - **pageNumber** (integer) - Optional - 要请求的页码,从1开始,如果没传,默认是第一页. - **pageSize** (integer) - Optional - 每页的记录数,默认20. #### Headers - **tenant-id** (string) - Required - `租户ID`,用于指标查询内容所在的租户. Max length: 32. - **auth-type** (string) - Required - `认证方式`,用于设置身份认证方式 UID:使用 UID 进行身份认证 TOKEN:使用 TOKEN 进行身份认证. Max length: 32. - **auth-value** (string) - Required - UID或者TOKEN值,与auth-type 类型选择一致. Max length: 32. ### Request Example ```json { "request": "GET http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/analysisview/list?keyword=order&pageNumber=1&pageSize=20\nHost: {anymetrics_host}\nAuthorization: Bearer {token}" } ``` ### Response #### Success Response (200) - **code** (string) - 接口响应码 - **message** (string) - 消息体 - **traceId** (string) - 跟踪ID,用于问题排查 - **data** (object) - 结果数据 - **pageNumber** (integer) - 当前页码 - **pageSize** (integer) - 每页条数 - **totalPageSize** (integer) - 总条数 - **data** (Array[Object]) - 当前页数据 - **id** (integer) - 指标视图id - **viewName** (string) - 指标视图名称 - **displayName** (string) - 指标视图展示名 - **description** (string) - 指标视图描述 - **metrics** (Array[string]) - 指标列表 - **dimensions** (Array[string]) - 维度列表 - **filters** (Array[string]) - 筛选器 - **time_constraint** (string) - 日期范围 - **orders** (Array[string]) - 查询的排序规则。引用的维度需要包含在“dimensions”参数中。 #### Response Example ```json { "code": "200", "message": "请求成功", "traceId": "fdde6861bd554805998343f9ff2dcd70.292.16857691758642861", "data": { "pageNumber": 1, "pageSize": 20, "total": 50, "data": [ { "id": 1, "viewName": "OrderAnalysisView2", "description": "订单指标视图2", "metrics": [ "orderCount" ], "dimensions": [ "stories/category" ], "filters": [ { "name": "stories/isDraft", "operator": "=", "values": [ "No" ] } ], "time_constraint":"BETWEEN 2023-01-01 AND 2023-01-10", "orders": [ { "stories/time": "asc" }, { "stories/count": "desc" } ] } ] } } ``` ``` -------------------------------- ### GET 请求类目列表 Source: https://docs.can.aloudata.com/API-%E7%B1%BB%E7%9B%AE%E5%88%97%E8%A1%A8 使用HTTP GET方法请求类目列表接口,需要指定类目类型作为查询参数。公共请求头中包含租户ID和认证信息。 ```HTTP GET Http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/category/list?categoryType=xxx ``` -------------------------------- ### API Response Example Source: https://docs.can.aloudata.com/API-%E6%A0%B9%E6%8D%AEID%E6%9F%A5%E8%AF%A2%E6%8C%87%E6%A0%87%E8%A7%86%E5%9B%BE%E8%AF%A6%E6%83%85 Example JSON response from the Anymetrics API for a successful metric view query. It illustrates the structure of the response, including the 'code', 'message', 'traceId', and the 'data' payload which contains detailed information about the metric view. ```json { "code": "200", "message": "请求成功", "traceId": "fdde6861bd554805998343f9ff2dcd70.292.16857691758642861", "data": [ { "id": 1, "viewName": "OrderAnalysisView2", "description": "订单指标视图2", "metrics": [ "orderCount" ], "dimensions": [ "stories/category" ], "filters": [ { "name": "stories/isDraft", "operator": "=", "values": [ "No" ] } ], "time_constraint":"BETWEEN 2023-01-01 AND 2023-01-10", "orders": [ { "stories/time": "asc" }, { "stories/count": "desc" } ] } ] } ``` -------------------------------- ### Request Body Examples for Querying Refresh Status Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 These examples demonstrate how to structure the request body to query the refresh status using either acceleration plan IDs or names. The API requires either a `planIdList` or a `planNameList`. ```json { "planIdList": [ "6665de58846daee543d5db415375d936", "e39daf5d7b8a7fd485177d4f1368971" ] } ``` ```json { "planNameList": [ "etstst", "v" ] } ``` -------------------------------- ### Semantic API Example URL Source: https://docs.can.aloudata.com/%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F This is an example URL for accessing the Semantic API, used for semantic-level API calls including metric queries and metric view result queries. The HOST_PORT needs to be obtained separately. ```http http://127.0.0.1:8085/semantic/api/v1.1/metrics/query ``` -------------------------------- ### Custom Expression Examples for Business Constraints Source: https://docs.can.aloudata.com/%E5%88%9B%E5%BB%BA%E6%B4%BE%E7%94%9F%E6%8C%87%E6%A0%87 Demonstrates how to use custom expressions for filtering data based on specific criteria. It includes examples for date-based filtering and filtering based on order status and payment channels. These expressions are crucial for defining precise business logic for derived metrics. ```SQL-like
[订单表/订单日期] >= Dateadd(Today(),-6,"DAY") AND [订单表/订单日期] <= Today()
``` ```SQL-like
[订单表/订单状态]="已支付" OR ([订单表/订单状态]="未支付" AND In([支付渠道/渠道],"支付宝","微信","银联支付"))
``` -------------------------------- ### Failed Response Example for Querying Refresh Status Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 This example illustrates a failed response from the Aloudata CAN API when querying the refresh status, indicating that the acceleration plan was not found. ```json { "data": null, "success": true, "code": "200", "errorMsg": "加速方案不存在", "detailErrorMsg": null, "traceId": "e78bba97f56f45d3a95d928de2cc4473.144.17193886412950007" } ``` -------------------------------- ### Successful Response Example for Querying Refresh Status Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 This example shows a successful response from the Aloudata CAN API when querying the refresh status. It includes details about whether tables are ready, the latest data time, and the latest refresh time. ```json { "data": { "hasNotReady": false, "latestDateTime": "2024-08-23 00:00:00", "latestRefreshTime": "2024-09-01 18:09:16" }, "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "a70c0ebdc9d04ce585bc2a3c85bfd83a.773.17252483988090161" } ``` -------------------------------- ### 查询应用加速详情 - HTTP GET Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E5%8A%A0%E9%80%9F%E8%AF%A6%E6%83%85%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 使用HTTP GET方法查询应用加速详情。需要提供anymetrics_host、anymetrics_port以及可选的planId或planName。公共请求参数包括tenant-id, auth-type, 和 auth-value。 ```http GET http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/accelerate/detail/query?planId=加速方案id&planName=加速方案名称 ``` -------------------------------- ### User Registration API Source: https://docs.can.aloudata.com/API-%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C Registers a new user account in the system. This is the initial interface used for system initialization and supports creating one account at a time. Batch user registration will be provided in a future version. ```APIDOC ## POST /anymetrics/api/v1/user/add ### Description Registers a new user account in the system. This is the initial interface used for system initialization and supports creating one account at a time. Batch user registration will be provided in a future version. ### Method POST ### Endpoint `Http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/user/add` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **account** (String) - Required - Maximum length 32 - The account name. - **password** (String) - Required - Maximum length 32 - The user's password. - **nickname** (String) - Required - Maximum length 64 - The user's nickname. ### Request Example ```json { "account":"account123", "password":"12345678", "nickname":"nickName123" } ``` ### Response #### Success Response (200) - **code** (String) - The API response code. - **success** (boolean) - Indicates if the request was successful. - **errorMsg** (String) - Error message if the request failed. - **detailErrorMsg** (String) - Detailed error message for failures. - **traceId** (String) - Unique identifier for tracing the request. - **data** (String) - The newly created user ID. #### Response Example ```json { "data": "478209624953061376", "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "2bc7df9f294144deab6535e0b2a9b546.155.17234444592120865" } ``` ``` -------------------------------- ### SQL: String start and endswith matching Source: https://docs.can.aloudata.com/%E4%B8%9A%E5%8A%A1%E9%99%90%E5%AE%9A This SQL snippet demonstrates how to filter string fields based on whether they start with, do not start with, end with, or do not end with a specific character or string. It provides examples using both ENDS_WITH/STARTS_WITH functions and the LIKE operator. ```sql ENDS_WITH (`user_name`, 'a') = FALSE --不以a结尾 ENDS_WITH (`user_name`, 'a') --以a结尾 STARTS_WITH (`user_name`, 'a') = FALSE --不以a开头 STARTS_WITH (`user_name`, 'a') --以a开头 user_name like 'a%' --查询以a开头的数据 user_name like '%a' --查询以a结尾的数据 ``` -------------------------------- ### 查询应用加速详情 - cURL请求 Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E5%8A%A0%E9%80%9F%E8%AF%A6%E6%83%85%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 使用cURL命令执行对应用加速详情的查询。该示例展示了如何设置必要的请求头,如auth-type, tenant-id, 和 auth-value,以及URL参数。 ```shell curl --location --request GET '{anymetrics_host:anymetrics_port}/anymetrics/api/v1/accelerate/detail/query?planName={planName}' \ --header 'auth-type: UID' \ --header 'tenant-id: tn_13943645' \ --header 'auth-value: 458221467125940224' ``` -------------------------------- ### Query Acceleration Details Source: https://docs.can.aloudata.com/API-%E6%9F%A5%E8%AF%A2%E5%8A%A0%E9%80%9F%E8%AF%A6%E6%83%85%28%E7%BB%93%E6%9E%9C%E5%8A%A0%E9%80%9F%29 This endpoint retrieves detailed information about a specific acceleration plan. It supports filtering by plan ID and plan name. ```APIDOC ## GET /anymetrics/api/v1/accelerate/detail/query ### Description Retrieves detailed information about an acceleration plan on the Aloudata CAN platform. The request can optionally include `planId` and `planName` for filtering. ### Method GET ### Endpoint `http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/accelerate/detail/query` ### Parameters #### Query Parameters - **planId** (String) - Optional - The ID of the acceleration plan. - **planName** (String) - Optional - The name of the acceleration plan. #### Request Headers - **tenant-id** (String) - Required - `租户ID`, the tenant ID for metric query content. - **auth-type** (String) - Required - Authentication type. Supported values: `UID` (User ID based authentication), `TOKEN` (Token based authentication). - **auth-value** (String) - Required - The authentication value corresponding to the selected `auth-type`. ### Request Example ```json { "request": "GET http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/accelerate/detail/query?planName={planName}&tenant-id=tn_13943645&auth-type=UID&auth-value=458221467125940224" } ``` ### Response #### Success Response (200) - **success** (Boolean) - Indicates if the request was successful. - **code** (String) - The API response code. - **errorMsg** (String) - Error message if the request failed. - **detailErrorMsg** (String) - Detailed error message for troubleshooting. - **traceId** (String) - Trace ID for problem investigation. - **data** (Object) - An object containing the acceleration plan details. - **planId** (String) - The ID of the acceleration plan. - **name** (String) - The name of the acceleration plan. - **displayName** (String) - The display name of the acceleration plan. - **dimensionList** (Array) - List of dimensions for the plan. - **metricList** (Array) - List of metrics for the plan. - **filterList** (Array) - List of filters applied to the plan. - **updateUpperInterval** (Number) - Upper interval for updates. - **updateLowerInterval** (Number) - Lower interval for updates. - **granularity** (String) - Granularity of the data (e.g., DAY). - **isScheduleUpdate** (Boolean) - Whether scheduled updates are enabled. - **cron** (String | null) - Cron expression for scheduling, if applicable. - **retryCount** (Number | null) - Number of retries for scheduled tasks. - **retryInterval** (Number | null) - Interval between retries. - **mvTableName** (String) - The materialized view table name. - **latestDataTime** (String) - The timestamp of the latest data. - **lastRefreshTime** (String) - The timestamp of the last refresh. - **dataRangeList** (Array) - List of data ranges. - **latestTaskDetail** (Object) - Details of the latest task. - **taskId** (String) - The ID of the task. - **taskStatus** (String) - The status of the task (e.g., SUCCESS). - **startTime** (String) - The start time of the task. - **finishedTime** (String) - The finish time of the task. - **message** (String | null) - Any message associated with the task. #### Response Example (Success) ```json { "data": { "planId": "a34bf995388080c979940f933ddae650", "name": "xm_result_demo", "displayName": "悬梦的API应用加速示例", "dimensionList": [ "metric_time__day", "user_name", "product_name" ], "metricList": [ "appspeed_countduser", "appspeed_amtsum" ], "filterList": [ "In([user_name], \"张三\")" ], "updateUpperInterval": 0, "updateLowerInterval": 0, "granularity": "DAY", "isScheduleUpdate": false, "cron": null, "retryCount": null, "retryInterval": null, "mvTableName": "xm_result_demo_mv_query_result_62f39eae", "latestDataTime": "2024-08-27 00:00:00", "lastRefreshTime": "2024-08-27 17:48:01", "dataRangeList": [], "latestTaskDetail": { "taskId": "4061", "taskStatus": "SUCCESS", "startTime": "2024-08-27 17:47:47", "finishedTime": "2024-08-27 17:48:01", "message": null } }, "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "434c61a28f9c446da2d6e012a2fabd62.161.17247520864110017" } ``` #### Response Example (Failure) ```json { "data": null, "success": true, "code": "200", "errorMsg": "加速方案不存在", "detailErrorMsg": null, "traceId": "e78bba97f56f45d3a95d928de2cc4473.144.17193886412950007" } ``` ``` -------------------------------- ### Request Token Creation - JSON Example Source: https://docs.can.aloudata.com/API-%E8%8E%B7%E5%8F%96%E8%AE%BF%E9%97%AE%E5%87%AD%E8%AF%81 Example of a JSON payload to request an access token from the Aloudata CAN metrics platform. It includes the application ID, application secret, and an optional expiration time in seconds. ```json { "appId": "03b34c53d4864da0995ecbcdbcf9ca65", "appSecret": "8K7BLJm0ZmzxtU7vfqF1ts5EO30WJMNQ", "expire": 3600 } ``` -------------------------------- ### Calculate Logarithm with Base 2 - Example Source: https://docs.can.aloudata.com/Log This example demonstrates how to use the Log function to calculate the base-2 logarithm for each value in a 'Value' field. It assumes a dataset with a 'Value' column. ```Example Log(Value, 2) ``` -------------------------------- ### 常规基础指标计算逻辑 Source: https://docs.can.aloudata.com/%E5%9F%BA%E7%A1%80%E6%8C%87%E6%A0%87%E8%AE%A1%E7%AE%97%E9%80%BB%E8%BE%91 展示了常规基础指标的查询流程,包括数据集确定、维度关联、筛选应用及统计方式执行。该逻辑适用于没有开启半累加配置的基础指标。 ```SQL SELECT SUM(订单表.订单金额 - 商品维度表.成本) FROM 订单表 JOIN 商品维度表 ON 订单表.商品ID = 商品维度表.商品ID WHERE DATE(订单表.下单时间) = '2024-09-30' AND 商品维度表.商品品类 = '电子产品'; ``` -------------------------------- ### 校验指标归因分析响应示例 Source: https://docs.can.aloudata.com/API-%E6%8C%87%E6%A0%87%E5%A4%9A%E7%BB%B4%E5%BD%92%E5%9B%A0%E5%88%86%E6%9E%90%E6%9F%A5%E8%AF%A2%E6%A0%A1%E9%AA%8C 展示了指标归因分析校验接口的成功响应体,包含数据结果(校验是否通过及不通过原因)、成功状态、响应码和 traceId。 ```json { "data": { "result": true, "errorMsg": null }, "success": true, "code": 200, "errorMsg": null, "traceId": "b6bbdc8f33f642de9a250e690238bdff.254.17067705870260001" } ``` -------------------------------- ### Floor Function Example: Rounding Down Numbers Source: https://docs.can.aloudata.com/Floor This example demonstrates how to use the Floor function to round down values from a 'Value' field. The function is applied to each numerical entry to obtain its floor value. ```plaintext Floor(Value) ``` -------------------------------- ### Power Function Example: Calculate Squares Source: https://docs.can.aloudata.com/Power Demonstrates how to use the Power function to calculate the square of values from a 'Value' field. This example illustrates a common use case for the function in data analysis. ```N/A Power(Value, 2) ``` -------------------------------- ### Extract Order Date Quarter - Pseudocode Example Source: https://docs.can.aloudata.com/Quarter This pseudocode example shows how to apply the Quarter function to an 'OrderDate' field to extract the quarter for each order. The function processes the date value and returns the quarter number. ```pseudocode Quarter(OrderDate) ``` -------------------------------- ### 校验指标归因分析请求示例 Source: https://docs.can.aloudata.com/API-%E6%8C%87%E6%A0%87%E5%A4%9A%E7%BB%B4%E5%BD%92%E5%9B%A0%E5%88%86%E6%9E%90%E6%9F%A5%E8%AF%A2%E6%A0%A1%E9%AA%8C 展示了调用指标归因分析校验接口的请求体,包括分析范围、指标名称、维度、时间约束、筛选器和返回行数等参数。 ```json { "analysisRange": { "current": "2024-05-11", "comparison": "2024-05-10" }, "metric": "ordercount_3", "dimensions": [ "order_id_2" ], "timeConstraint": {}, "filters": [], "limit": 2 } ``` -------------------------------- ### Example: Replacing Brand Name in Product Description Source: https://docs.can.aloudata.com/Replace This example demonstrates how to use the Replace function to change brand names within a product description field. It illustrates a practical application for data cleaning and standardization. ```formula Replace(ProductDescription, "Apple", "Samsung") ``` -------------------------------- ### 半累加基础指标计算逻辑 Source: https://docs.can.aloudata.com/%E5%9F%BA%E7%A1%80%E6%8C%87%E6%A0%87%E8%AE%A1%E7%AE%97%E9%80%BB%E8%BE%91 演示了半累加基础指标的计算过程,重点在于处理不可累加维度(如日期)和窗口选择(如最大值)。适用于数据包含快照且部分维度不可聚合的场景。 ```SQL SELECT SUM(存款记录.存款金额) FROM ( SELECT 存款记录.*, ROW_NUMBER() OVER(PARTITION BY 账户ID, 存折号 ORDER BY 日期 DESC) as rn FROM 存款记录 WHERE STRFTIME('%Y-%m', 日期) = '2024-09' ) AS 存款记录 WHERE rn = 1 GROUP BY 账户ID, 存折号; ``` -------------------------------- ### Example: Calculating Modulo with a Field and Constant Source: https://docs.can.aloudata.com/Mod This example demonstrates how to use the Mod function to calculate the remainder of a field's values when divided by a constant. It's useful for categorizing or processing data based on divisibility. ```N/A Mod(Value, 3) ``` -------------------------------- ### Ceil Function Example Usage Source: https://docs.can.aloudata.com/Ceil This example demonstrates how to use the Ceil function with a 'Value' field to round up each numerical entry to the nearest integer. The input consists of various numerical values, and the output shows the corresponding rounded-up integers. ```plaintext Ceil(Value) ``` -------------------------------- ### Ln Function Example - Calculating Natural Logarithm Source: https://docs.can.aloudata.com/Ln This example demonstrates how to use the Ln function to calculate the natural logarithm for values in a 'Value' field. The function takes the 'Value' field as input and outputs the natural logarithm. ```plaintext Ln(Value) ``` -------------------------------- ### Example: Filter Orders with Non-Null Order Amount (DSL) Source: https://docs.can.aloudata.com/NotNull This example demonstrates how to use the NotNull function to filter records from an order table. It specifically selects orders where the 'OrderAmount' field is not null. This is a common use case for data subsetting and reporting. ```DSL NotNull(OrderAmount) ``` -------------------------------- ### SQL: 创建毛利润基础指标 Source: https://docs.can.aloudata.com/%E5%88%9B%E5%BB%BA%E5%9F%BA%E7%A1%80%E6%8C%87%E6%A0%87 此SQL查询用于计算毛利润,通过连接订单表和产品表,计算每个订单的销售额减去产品成本的总和。该查询是基于多数据集创建基础指标的示例。 ```sql SELECT Datetrunc(订单表.下单时间,"DAY"),Sum(订单表.订单金额-产品表.产品成本) FROM 订单表 LEFT JOIN 产品表 ON 订单表.产品ID=产品表.产品ID GROUP BY Datetrunc(订单表.下单时间,"DAY") ``` -------------------------------- ### Dimension Value Preview Response Example (JSON) Source: https://docs.can.aloudata.com/API-%E7%BB%B4%E5%BA%A6%E5%80%BC%E9%A2%84%E8%A7%88 This JSON object illustrates a successful response from the dimension value preview API. It includes a status code, success flag, and detailed data. The `data` object contains query details, metadata about the fields, and the actual dimension values. ```json { "data": { "queryId": "4e06378a84af4f0f98333ff31ed6ad1c", "warning": null, "sql": "SELECT `tn_597771_correctness_test_qq_datasource__default__can_shop`.`shop_id`\nFROM `default_catalog`.`aloudatacan`.`tn_597771_correctness_test_qq_datasource__default__can_shop` AS `tn_597771_correctness_test_qq_datasource__default__can_shop`\nGROUP BY `tn_597771_correctness_test_qq_datasource__default__can_shop`.`shop_id`\nORDER BY (`tn_597771_correctness_test_qq_datasource__default__can_shop`.`shop_id`) IS NULL, `tn_597771_correctness_test_qq_datasource__default__can_shop`.`shop_id`\nLIMIT 200", "metas": [ { "id": null, "name": "shop_id", "type": "INT", "displayName": null, "format": null, "description": null, "sourceType": null, "dataType": null, "columnFormat": null } ], "table": { "shop_id": [ [ 1, 1, null ], [ 2, 1, null ], [ 3, 1, null ], [ 4, 1, null ], [ 5, 1, null ], [ 6, 1, null ], [ 7, 1, null ], [ 8, 1, null ] ] } }, "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "ad3cd6c9fd5849b6a271f02f89edc93e.145.17193921246800027" } ``` -------------------------------- ### Check if String Starts With Substring Source: https://docs.can.aloudata.com/StartWith The StartWith function evaluates if a string begins with a specified substring. It takes the main string and the substring to check as parameters and returns true if the string starts with the substring, false otherwise. This is useful for filtering data based on prefixes. ```General StartWith(<字符串>, <子字符串>) ``` ```General StartWith(ProductName, "Apple") ``` -------------------------------- ### Delete Metric Request Example (JSON) Source: https://docs.can.aloudata.com/API-%E5%88%A0%E9%99%A4%E6%8C%87%E6%A0%87 Example JSON payload for the metric deletion API. It requires the 'metricName' to identify which metric to delete. This is sent as the request body. ```json { "metricName":"OrderCount" } ``` -------------------------------- ### Analysis Book Module and Visualization (SQL) Source: https://docs.can.aloudata.com/%E4%BA%A7%E5%93%81%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97 Announces the new analysis book module, which provides visualization tools like pivot tables, bar charts, bar charts, and pie charts for analyzing metrics. ```SQL 新增分析簿模块 提供透视表、柱状图、条形图、饼图的可视化分析指标功能 ``` -------------------------------- ### Default Login Method Setting (SQL) Source: https://docs.can.aloudata.com/%E4%BA%A7%E5%93%81%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97 Explains the feature to set a default login method, simplifying the user login process. ```SQL 支持设置默认的登录方式 ``` -------------------------------- ### API Response Example Source: https://docs.can.aloudata.com/%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F This is an example JSON response from an Aloudata CAN API. It indicates the success status, a status code, and potentially an error message if the operation failed. ```json { "data": true, "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "" } ``` -------------------------------- ### Example: Checking Product Description for Keywords Source: https://docs.can.aloudata.com/Contains This example demonstrates how to use the 'Contains' function to check if a product description field includes a specific keyword ('Pro'). It illustrates a practical application for filtering data based on string content. The function returns true if the keyword is found, and false otherwise. ```plaintext Contains(ProductDescription, "Pro") ``` -------------------------------- ### Batch Upload of Metric Basic Information (SQL) Source: https://docs.can.aloudata.com/%E4%BA%A7%E5%93%81%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97 Describes the functionality for batch uploading basic metric information, streamlining the process of creating multiple metrics simultaneously. ```SQL 支持批量上传指标基础信息,创建指标 ``` -------------------------------- ### DateAdd Function Example: Adding 30 Days to Order Dates Source: https://docs.can.aloudata.com/DateAdd This example demonstrates how to use the DateAdd function to add 30 days to an 'OrderDate' field. The function takes the 'OrderDate' field, the integer 30, and the string 'day' as arguments. The output shows the original order date and the newly calculated date. ```N/A DateAdd(OrderDate, 30, "day") ``` -------------------------------- ### 帆软BI数据连接配置示例 (Doris/Starrocks) Source: https://docs.can.aloudata.com/%E5%B8%86%E8%BD%AFBI%E9%9B%86%E6%88%90 根据指标平台数据源类型(Doris 或 Starrocks),选择合适的账号平台(MySQL 或 Doris/StarRocks)进行配置。 ```text 若指标平台数据源为 Doris 可以先用账号平台为 MySQL 或者 Doris。 若指标平台数据源为 Starrocks 可以选用账号平台为 MySQL 或者 StarRocks。 ``` -------------------------------- ### Create Dataset Relation Response Example (JSON) Source: https://docs.can.aloudata.com/API-%E6%96%B0%E5%A2%9E%E5%85%B3%E7%B3%BB An example of the JSON response received after successfully creating a dataset relation. It confirms the success of the operation and provides the ID of the newly created relation. ```json { "data": { "relationId": "relation_12" }, "success": true, "code": null, "message": null, "traceId": "" } ``` -------------------------------- ### Create Dataset Relation Request Example (JSON) Source: https://docs.can.aloudata.com/API-%E6%96%B0%E5%A2%9E%E5%85%B3%E7%B3%BB An example of the JSON payload required to create a dataset relation. It includes the source and destination dataset names, the type of relation, and the conditions for the relation. ```json { "srcDatasetName": "oracle_product_1", "type": "MANY_TO_ONE", "relationConditions": [ { "srcExpr": "[oracle_product_1/SHOP_ID]", "dstExpr": "[oracle_shop/SHOP_ID]" } ], "dstDatasetName": "oracle_shop" } ``` -------------------------------- ### 指标多维归因分析响应示例 Source: https://docs.can.aloudata.com/API-%E6%8C%87%E6%A0%87%E5%A4%9A%E7%BB%B4%E5%BD%92%E5%9B%A0%E5%88%86%E6%9E%90%E6%9F%A5%E8%AF%A2 这是一个指标多维归因分析查询接口的响应示例。它包含了接口响应码、消息、traceId以及归因分析的结果数据,包括指标、所有维度的汇总信息(当前值、对比值、增长、增长率、贡献率)以及具体维度的详细数据。 ```json { "data": { "metric": "testtesttest", "table": { "all": { "dimensionValue": null, "currentValue": 90.0, "comparisonValue": 0.0, "growth": 90.0, "growthRate": 9.0E7, "overallContributionRate": null, "relativeContributionRate": null }, "dimensions": { "BWBDM": { "dimensionValue": [ "RMB" ], "currentValue": [ 90.0 ], "comparisonValue": [ 0.0 ], "growth": [ 90.0 ], "growthRate": [ 9.0E7 ], "overallContributionRate": [ 1.0 ], "relativeContributionRate": null } } } }, "success": true, "code": "200", "errorMsg": null, "detailErrorMsg": null, "traceId": "d6b9429207254f6883edddc1ad5ec14e.28656.17353825580631533" } ``` -------------------------------- ### 帆软BI数据连接配置示例 (FineBI) Source: https://docs.can.aloudata.com/%E5%B8%86%E8%BD%AFBI%E9%9B%86%E6%88%90 此配置适用于在 FineBI 中连接 Aloudata CAN。请根据 Aloudata CAN 提供的地址、端口、catalog、schema、用户名和密码填写。 ```text 数据库地址: [Aloudata CAN 地址] 端口号: [Aloudata CAN 端口] 用户名: [Aloudata CAN 用户名] 密码: [Aloudata CAN 登录密码] 数据库名称: [Aloudata CAN Schema] 连接 URL 格式: [Aloudata CAN 地址]:[Aloudata CAN 端口]/[Aloudata CAN Catalog].[Aloudata CAN Schema] ``` -------------------------------- ### Delete Metric Response Example (JSON) Source: https://docs.can.aloudata.com/API-%E5%88%A0%E9%99%A4%E6%8C%87%E6%A0%87 Example JSON response from the metric deletion API. It indicates the success or failure of the operation with a 'code', 'message', 'traceId', and a boolean 'data' field indicating the result. ```json { "code":"200", "message":"请求成功", "traceId":"fdde6861bd554805998343f9ff2dcd70.292.16857691758642861", "data":true } ``` -------------------------------- ### AnyMetrics API Example URL Source: https://docs.can.aloudata.com/%E8%B0%83%E7%94%A8%E6%96%B9%E5%BC%8F This is an example URL for accessing the AnyMetrics API, which is used for product-level API calls such as credential management, dimension management, and metric management. The HOST_PORT needs to be obtained separately. ```http http://127.0.0.1:8083/anymetrics/api/v1/metrics/create ``` -------------------------------- ### POST /anymetrics/api/v1/dataset/create Source: https://docs.can.aloudata.com/API-%E6%96%B0%E5%A2%9E%E6%95%B0%E6%8D%AE%E9%9B%86 Creates a new dataset in the metrics platform. This endpoint allows specifying dataset details, including its name, display name, description, category, source information, and column definitions. ```APIDOC ## POST /anymetrics/api/v1/dataset/create ### Description Creates a new dataset in the metrics platform. This endpoint allows specifying dataset details, including its name, display name, description, category, source information, and column definitions. ### Method POST ### Endpoint `Http://{anymetrics_host:anymetrics_port}/anymetrics/api/v1/dataset/create` ### Parameters #### Path Parameters - **anymetrics_host** (string) - Required - Host of the metrics platform. - **anymetrics_port** (integer) - Required - Port of the metrics platform. #### Query Parameters - **tenant-id** (string) - Required - Current tenant ID. (e.g., `tn_125288`) - **auth-type** (string) - Required - Authentication type (UID/TOKEN). (e.g., `UID`) - **auth-value** (string) - Required - UID or TOKEN value. (e.g., `341523017135816704`) #### Request Body - **name** (string) - Required - Dataset name. Max length: 128. (e.g., `datasetName`) - **displayName** (string) - Required - Dataset display name. Max length: 128. (e.g., `dataset123`) - **description** (string) - Optional - Dataset description. Max length: 256. (e.g., `交易记录数据集`) - **categoryId** (string) - Optional - Dataset category ID. - **sourceInfo** (object) - Required - Source information. See Sub-table 1 for details. - **defColumns** (array) - Optional - Array of column definitions. See Sub-table 2 for element structure. **Sub-table 1: sourceInfo Parameters** - **name** (string) - Required - Source table name. Max length: 32. (e.g., `datet`) - **displayName** (string) - Required - Source table display name. Max length: 128. (e.g., `dataset123`) - **description** (string) - Required - Source table description. Max length: 256. (e.g., `交易记录数据集`) - **content** (string) - Required - Source data content (GUID for physical tables, SQL statement for SQL sources). (e.g., `jmsr.`default_catalog.jingming`.datet`) - **type** (string) - Required - Source data type (TABLE or SQL). (e.g., `TABLE`) - **datasourceItems** (array) - Optional - Data source items array (currently supports one element, including data source GUID, name, and engine type). (e.g., `[{"id":"jmsr", "name":"jmsR", "queryEngineType":"STARROCKS"}]`) **Sub-table 2: defColumns Parameters** - **name** (string) - Required - Field name (cannot be modified). Max length: 128. - **displayName** (string) - Required - Field display name. Max length: 128. - **description** (string) - Optional - Column description. Max length: 256. - **type** (string) - Required - Column type (ENUM: DIMENSION/MEASURE). - **expr** (string) - Required - Field expression. (e.g., `['datet'/'date_type']`) - **sourceColumn** (string) - Optional - Source field (required for physical table fields). Max length: 128. ### Request Example ```json { "name": "datetapi", "displayName": "datetapi", "description": "datetapi", "sourceInfo": { "name": "datet", "displayName": "datet", "description": "sad", "content": "jmsr.`default_catalog.jingming`.datet", "type": "TABLE", "datasourceItems": [ { "id": "jmsr", "name": "jmsR", "queryEngineType": "STARROCKS" } ] } } ``` ### Response #### Success Response (200) - **data** (boolean) - Indicates if the operation was successful. - **success** (boolean) - Indicates overall success status. - **code** (integer) - HTTP status code. - **message** (any) - Null or contains an error message if applicable. - **traceId** (string) - Unique identifier for tracing the request. #### Response Example ```json { "data": true, "success": true, "code": 200, "message": null, "traceId": "" } ``` ``` -------------------------------- ### PowerAdd Example: Calculating Max Sales by Product Type Source: https://docs.can.aloudata.com/PowerAdd This example illustrates how to use the PowerAdd function in conjunction with the MAX aggregation function to calculate the maximum sales amount for different product types within a specific date. It shows how to define levels and add summary values based on the PowerAdd calculation. ```DAX [最畅销类型产品的销售额] = MAX( PowerAdd( SUM('订单表'[订单金额]) ,'产品表'[产品类型]) ) ```