Repository: dbt-labs/dbt-core

Issue:
[CT-2684] NodeType strings should not contain spaces
The string representations of `NodeType` enum should not contain spaces. They should be snake case, or ideally a single word.

This affects how we construct the node's `unique_id`, which also affects its key in the manifest, how it appears in structured logging, etc.

This is currently relevant for "SQL operations" (a.k.a. "inline" queries) and "semantic models."

https://github.com/dbt-labs/dbt-core/blob/6f51de4cb5ed91125772ceae69acb1c22c00e834/core/dbt/node_types.py#L29

https://github.com/dbt-labs/dbt-core/blob/6f51de4cb5ed91125772ceae69acb1c22c00e834/core/dbt/node_types.py#L36


Discussion:
Yeah, I was wondering about this even when I did it. Since we are following up a bunch of Sematnic Interfaces issues right now, I'll add this to the list.

Resolving patch:
diff --git a/core/dbt/node_types.py b/core/dbt/node_types.py
--- a/core/dbt/node_types.py
+++ b/core/dbt/node_types.py
@@ -26,14 +26,14 @@ class NodeType(StrEnum):
     Seed = "seed"
     # TODO: rm?
     RPCCall = "rpc"
-    SqlOperation = "sqloperation"
+    SqlOperation = "sql_operation"
     Documentation = "doc"
     Source = "source"
     Macro = "macro"
     Exposure = "exposure"
     Metric = "metric"
     Group = "group"
-    SemanticModel = "semanticmodel"
+    SemanticModel = "semantic_model"
 
     @classmethod
     def executable(cls) -> List["NodeType"]:


Test patch:
diff --git a/tests/functional/semantic_models/test_semantic_model_parsing.py b/tests/functional/semantic_models/test_semantic_model_parsing.py
--- a/tests/functional/semantic_models/test_semantic_model_parsing.py
+++ b/tests/functional/semantic_models/test_semantic_model_parsing.py
@@ -77,7 +77,7 @@ def test_semantic_model_parsing(self, project):
         assert isinstance(result.result, Manifest)
         manifest = result.result
         assert len(manifest.semantic_models) == 1
-        semantic_model = manifest.semantic_models["semanticmodel.test.revenue"]
+        semantic_model = manifest.semantic_models["semantic_model.test.revenue"]
         assert semantic_model.node_relation.alias == "fct_revenue"
         assert (
             semantic_model.node_relation.relation_name
@@ -102,5 +102,5 @@ def test_semantic_model_partial_parsing(self, project):
 
         # Finally, verify that the manifest reflects the partially parsed change
         manifest = result.result
-        semantic_model = manifest.semantic_models["semanticmodel.test.revenue"]
+        semantic_model = manifest.semantic_models["semantic_model.test.revenue"]
         assert semantic_model.dimensions[0].type_params.time_granularity == TimeGranularity.WEEK
diff --git a/tests/unit/test_node_types.py b/tests/unit/test_node_types.py
--- a/tests/unit/test_node_types.py
+++ b/tests/unit/test_node_types.py
@@ -9,14 +9,14 @@
     NodeType.Operation: "operations",
     NodeType.Seed: "seeds",
     NodeType.RPCCall: "rpcs",
-    NodeType.SqlOperation: "sqloperations",
+    NodeType.SqlOperation: "sql_operations",
     NodeType.Documentation: "docs",
     NodeType.Source: "sources",
     NodeType.Macro: "macros",
     NodeType.Exposure: "exposures",
     NodeType.Metric: "metrics",
     NodeType.Group: "groups",
-    NodeType.SemanticModel: "semanticmodels",
+    NodeType.SemanticModel: "semantic_models",
 }