Skip to content

Commit

Permalink
updated parser
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Nov 16, 2023
1 parent c3804ac commit b4dd97e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@
},
"type": "object"
},
"conversion_type_params_schema": {
"$id": "conversion_type_params_schema",
"additionalProperties": false,
"properties": {
"base_measure": {
"$ref": "#/definitions/metric_input_measure_schema"
},
"calculation": {
"enum": [
"CONVERSIONS",
"CONVERSION_RATE",
"conversions",
"conversion_rate"
]
},
"conversion_measure": {
"$ref": "#/definitions/metric_input_measure_schema"
},
"entity": {
"type": "string"
},
"window": {
"type": "string"
}
},
"required": [
"base_measure",
"conversion_measure",
"entity"
],
"type": "object"
},
"dimension_schema": {
"$id": "dimension_schema",
"additionalProperties": false,
Expand Down Expand Up @@ -347,10 +379,12 @@
"RATIO",
"CUMULATIVE",
"DERIVED",
"CONVERSION",
"simple",
"ratio",
"cumulative",
"derived"
"derived",
"conversion"
]
},
"type_params": {
Expand All @@ -368,6 +402,9 @@
"$id": "metric_type_params",
"additionalProperties": false,
"properties": {
"conversion_type_params": {
"$ref": "#/definitions/conversion_type_params_schema"
},
"denominator": {
"$ref": "#/definitions/metric_input_measure_schema"
},
Expand Down
21 changes: 20 additions & 1 deletion dbt_semantic_interfaces/parsing/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@


# Enums
metric_types_enum_values = ["SIMPLE", "RATIO", "CUMULATIVE", "DERIVED"]
metric_types_enum_values = ["SIMPLE", "RATIO", "CUMULATIVE", "DERIVED", "CONVERSION"]
metric_types_enum_values += [x.lower() for x in metric_types_enum_values]

calculation_types_enum_values = ["CONVERSIONS", "CONVERSION_RATE"]
calculation_types_enum_values += [x.lower() for x in calculation_types_enum_values]

entity_type_enum_values = ["PRIMARY", "UNIQUE", "FOREIGN", "NATURAL"]
entity_type_enum_values += [x.lower() for x in entity_type_enum_values]

Expand Down Expand Up @@ -85,6 +88,20 @@
"additionalProperties": False,
}

conversion_type_params_schema = {
"$id": "conversion_type_params_schema",
"type": "object",
"properties": {
"base_measure": {"$ref": "metric_input_measure_schema"},
"conversion_measure": {"$ref": "metric_input_measure_schema"},
"calculation": {"enum": calculation_types_enum_values},
"entity": {"type": "string"},
"window": {"type": "string"},
},
"additionalProperties": False,
"required": ["base_measure", "conversion_measure", "entity"],
}

metric_type_params_schema = {
"$id": "metric_type_params",
"type": "object",
Expand All @@ -99,6 +116,7 @@
"type": "array",
"items": {"$ref": "metric_input_schema"},
},
"conversion_type_params": {"$ref": "conversion_type_params_schema"},
},
"additionalProperties": False,
}
Expand Down Expand Up @@ -382,6 +400,7 @@
filter_schema["$id"]: filter_schema,
metric_input_measure_schema["$id"]: metric_input_measure_schema,
metric_type_params_schema["$id"]: metric_type_params_schema,
conversion_type_params_schema["$id"]: conversion_type_params_schema,
entity_schema["$id"]: entity_schema,
measure_schema["$id"]: measure_schema,
dimension_schema["$id"]: dimension_schema,
Expand Down

0 comments on commit b4dd97e

Please sign in to comment.