windmill_api/models/data_metric.rs
1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.765.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// DataMetric : One `// measure` or `// dimension` declaration, as catalogued from the script that materializes the table. `expr` and `filter` are the author's own SQL: a reader renders a measure as `expr` plus, when `filter` is set, a trailing `FILTER (WHERE filter)`.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct DataMetric {
17 /// The declaring script, and the path reads are authorized against
18 #[serde(rename = "script_path")]
19 pub script_path: String,
20 /// Canonical scheme-less DuckLake path, `<lake>/<schema>.<table>` (schema defaults to `main`)
21 #[serde(rename = "table_path")]
22 pub table_path: String,
23 #[serde(rename = "kind")]
24 pub kind: Kind,
25 #[serde(rename = "name")]
26 pub name: String,
27 #[serde(rename = "expr")]
28 pub expr: String,
29 /// Row predicate from a measure's trailing `where`
30 #[serde(rename = "filter", skip_serializing_if = "Option::is_none")]
31 pub filter: Option<String>,
32}
33
34impl DataMetric {
35 /// One `// measure` or `// dimension` declaration, as catalogued from the script that materializes the table. `expr` and `filter` are the author's own SQL: a reader renders a measure as `expr` plus, when `filter` is set, a trailing `FILTER (WHERE filter)`.
36 pub fn new(script_path: String, table_path: String, kind: Kind, name: String, expr: String) -> DataMetric {
37 DataMetric {
38 script_path,
39 table_path,
40 kind,
41 name,
42 expr,
43 filter: None,
44 }
45 }
46}
47///
48#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
49pub enum Kind {
50 #[serde(rename = "measure")]
51 Measure,
52 #[serde(rename = "dimension")]
53 Dimension,
54}
55
56impl Default for Kind {
57 fn default() -> Kind {
58 Self::Measure
59 }
60}
61