Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify node statistic tabulation.
  • Loading branch information
peterallenwebb committed Jul 12, 2023
commit 4fbf0373c073ea3796aea44c521cb4f320b1ed2d
27 changes: 9 additions & 18 deletions core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,17 @@ def _generate_stats(manifest: Manifest):
if _node_enabled(node):
stats[node.resource_type] += 1

for source in manifest.sources.values():
stats[source.resource_type] += 1
for exposure in manifest.exposures.values():
stats[exposure.resource_type] += 1
for metric in manifest.metrics.values():
stats[metric.resource_type] += 1
for macro in manifest.macros.values():
stats[macro.resource_type] += 1
for group in manifest.groups.values():
stats[group.resource_type] += 1
# REVIEW: Why are these counted if disabled, when nodes in the general node
# collection are not?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poked into this -- I believe it's because the disabled mapping on the manifest stores a broader set of node types (GraphMemberNode) than the general node collection. For example, disabled exposures would be omitted from manifest.exposures and instead find themselves in manifest.disabled and so would not get included in the count. It looks like the _node_enabled is really just handling NodeType.Test resources which presumably find themselves in manifest.nodes even if they are disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does make sense. I'll remove the comment.

stats[NodeType.Source] += len(manifest.sources)
stats[NodeType.Exposure] += len(manifest.exposures)
stats[NodeType.Metric] += len(manifest.metrics)
stats[NodeType.Macro] += len(manifest.macros)
stats[NodeType.Group] += len(manifest.groups)
stats[NodeType.SemanticModel] += len(manifest.semantic_models)

# TODO: should we be counting dimensions + entities?
# dimensions = set()
# entities = set()
for semantic_model in manifest.semantic_models.values():
stats[semantic_model.resource_type] += 1
# for dimension in semantic_model.dimensions:
# dimensions.add(dimension.name)
# for entity in semantic_model.entities:
# entities.add(entity.name)

return stats


Expand Down