Skip to content

Commit

Permalink
updated parser
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Nov 26, 2023
1 parent a8a4f2a commit 8c2f986
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,61 @@
},
"type": "object"
},
"constant_property_input_schema": {
"$id": "constant_property_input_schema",
"additionalProperties": false,
"properties": {
"base_property": {
"type": "string"
},
"conversion_property": {
"type": "string"
}
},
"required": [
"base_property",
"conversion_property"
],
"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"
]
},
"constant_properties": {
"items": {
"$ref": "#/definitions/constant_property_input_schema"
},
"type": "array"
},
"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 +402,12 @@
"RATIO",
"CUMULATIVE",
"DERIVED",
"CONVERSION",
"simple",
"ratio",
"cumulative",
"derived"
"derived",
"conversion"
]
},
"type_params": {
Expand All @@ -368,6 +425,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
34 changes: 33 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,32 @@
"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"},
"constant_properties": {"type": "array", "items": {"$ref": "constant_property_input_schema"}},
},
"additionalProperties": False,
"required": ["base_measure", "conversion_measure", "entity"],
}

constant_property_input_schema = {
"$id": "constant_property_input_schema",
"type": "object",
"properties": {
"base_property": {"type": "string"},
"conversion_property": {"type": "string"},
},
"additionalProperties": False,
"required": ["base_property", "conversion_property"],
}

metric_type_params_schema = {
"$id": "metric_type_params",
"type": "object",
Expand All @@ -99,6 +128,7 @@
"type": "array",
"items": {"$ref": "metric_input_schema"},
},
"conversion_type_params": {"$ref": "conversion_type_params_schema"},
},
"additionalProperties": False,
}
Expand Down Expand Up @@ -382,6 +412,8 @@
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,
constant_property_input_schema["$id"]: constant_property_input_schema,
entity_schema["$id"]: entity_schema,
measure_schema["$id"]: measure_schema,
dimension_schema["$id"]: dimension_schema,
Expand Down

0 comments on commit 8c2f986

Please sign in to comment.