dbt-cube-sync 0.1.0a12__tar.gz → 0.1.0a13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dbt-cube-sync might be problematic. Click here for more details.

Files changed (17) hide show
  1. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/PKG-INFO +1 -1
  2. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/state_manager.py +36 -5
  3. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/pyproject.toml +1 -1
  4. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/README.md +0 -0
  5. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/__init__.py +0 -0
  6. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/cli.py +0 -0
  7. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/config.py +0 -0
  8. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/connectors/__init__.py +0 -0
  9. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/connectors/base.py +0 -0
  10. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/connectors/powerbi.py +0 -0
  11. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/connectors/superset.py +0 -0
  12. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/connectors/tableau.py +0 -0
  13. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/__init__.py +0 -0
  14. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/cube_generator.py +0 -0
  15. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/db_inspector.py +0 -0
  16. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/dbt_parser.py +0 -0
  17. {dbt_cube_sync-0.1.0a12 → dbt_cube_sync-0.1.0a13}/dbt_cube_sync/core/models.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dbt-cube-sync
3
- Version: 0.1.0a12
3
+ Version: 0.1.0a13
4
4
  Summary: Synchronization tool for dbt models to Cube.js schemas and BI tools
5
5
  Author: Ponder
6
6
  Requires-Python: >=3.9,<4.0
@@ -4,6 +4,7 @@ State management for incremental sync functionality.
4
4
  Tracks model checksums to enable incremental sync - only regenerate
5
5
  Cube.js files for models that have actually changed.
6
6
  """
7
+ import hashlib
7
8
  import json
8
9
  import os
9
10
  from datetime import datetime
@@ -13,6 +14,34 @@ from typing import Dict, List, Optional, Set, Tuple
13
14
  from .models import ModelState, SyncState
14
15
 
15
16
 
17
+ def compute_model_checksum(node_data: dict) -> str:
18
+ """
19
+ Compute a checksum that includes both the dbt model checksum
20
+ and the metrics/meta configuration.
21
+
22
+ This ensures that changes to metrics (which don't change the SQL)
23
+ are still detected as modifications.
24
+
25
+ Args:
26
+ node_data: The node data from the dbt manifest
27
+
28
+ Returns:
29
+ A combined SHA256 checksum string
30
+ """
31
+ # Get the base dbt checksum
32
+ base_checksum = node_data.get("checksum", {}).get("checksum", "")
33
+
34
+ # Get the meta configuration (where metrics are defined)
35
+ meta = node_data.get("config", {}).get("meta", {})
36
+
37
+ # Serialize meta to a stable JSON string (sorted keys for consistency)
38
+ meta_json = json.dumps(meta, sort_keys=True, default=str)
39
+
40
+ # Combine and hash
41
+ combined = f"{base_checksum}:{meta_json}"
42
+ return hashlib.sha256(combined.encode()).hexdigest()
43
+
44
+
16
45
  class StateManager:
17
46
  """Manages sync state for incremental model generation."""
18
47
 
@@ -86,11 +115,11 @@ class StateManager:
86
115
  removed = previous_node_ids - current_node_ids
87
116
 
88
117
  # Find modified models (in both, but checksum changed)
118
+ # Note: We compute a combined checksum that includes metrics/meta config,
119
+ # not just the dbt SQL checksum. This ensures metric changes are detected.
89
120
  modified = set()
90
121
  for node_id in current_node_ids & previous_node_ids:
91
- current_checksum = manifest_nodes[node_id].get("checksum", {}).get(
92
- "checksum", ""
93
- )
122
+ current_checksum = compute_model_checksum(manifest_nodes[node_id])
94
123
  previous_checksum = previous_state.models[node_id].checksum
95
124
  if current_checksum != previous_checksum:
96
125
  modified.add(node_id)
@@ -121,7 +150,8 @@ class StateManager:
121
150
  if node_id not in generated_files:
122
151
  continue
123
152
 
124
- checksum = node_data.get("checksum", {}).get("checksum", "")
153
+ # Use combined checksum that includes metrics/meta config
154
+ checksum = compute_model_checksum(node_data)
125
155
  has_metrics = bool(
126
156
  node_data.get("config", {}).get("meta", {}).get("metrics")
127
157
  )
@@ -174,7 +204,8 @@ class StateManager:
174
204
  # Update/add newly generated models
175
205
  for node_id, output_file in generated_files.items():
176
206
  node_data = manifest_nodes.get(node_id, {})
177
- checksum = node_data.get("checksum", {}).get("checksum", "")
207
+ # Use combined checksum that includes metrics/meta config
208
+ checksum = compute_model_checksum(node_data)
178
209
  has_metrics = bool(
179
210
  node_data.get("config", {}).get("meta", {}).get("metrics")
180
211
  )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dbt-cube-sync"
3
- version = "0.1.0a12"
3
+ version = "0.1.0a13"
4
4
  description = "Synchronization tool for dbt models to Cube.js schemas and BI tools"
5
5
  authors = ["Ponder"]
6
6
  readme = "README.md"