From 0ace6d6b03f425c9cc5a2edeffbb186991f89ec9 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 6 Sep 2024 10:53:59 -0700 Subject: [PATCH] Remove unnecessary `deepcopy` call (#1345) This PR removes a `deepcopy` call that is used when fetching dimensions. The call seems unnecessary as the manifest should not be modified during a query. This call was also found to have a significant impact in performance during profiling. --- .../model/semantics/semantic_model_lookup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/model/semantics/semantic_model_lookup.py b/metricflow-semantics/metricflow_semantics/model/semantics/semantic_model_lookup.py index df32102085..59931b2090 100644 --- a/metricflow-semantics/metricflow_semantics/model/semantics/semantic_model_lookup.py +++ b/metricflow-semantics/metricflow_semantics/model/semantics/semantic_model_lookup.py @@ -1,7 +1,6 @@ from __future__ import annotations import logging -from copy import deepcopy from typing import Dict, List, Optional, Sequence, Set from dbt_semantic_interfaces.protocols.dimension import Dimension @@ -92,13 +91,11 @@ def get_dimension(self, dimension_reference: DimensionReference) -> Dimension: f"Could not find dimension with name '{dimension_reference.element_name}' in configured semantic models" ) - dimension = SemanticModelLookup.get_dimension_from_semantic_model( + return SemanticModelLookup.get_dimension_from_semantic_model( # Dimension object should match across semantic models, so just use the first semantic model. semantic_model=semantic_models[0], dimension_reference=dimension_reference, ) - # TODO: Unclear if the deepcopy is necessary. - return deepcopy(dimension) def get_time_dimension(self, time_dimension_reference: TimeDimensionReference) -> Dimension: """Retrieves a full dimension object by name."""