dbt-cube-sync 0.1.0a3__tar.gz → 0.1.0a4__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.
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/PKG-INFO +1 -1
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/connectors/superset.py +41 -23
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/pyproject.toml +1 -1
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/README.md +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/__init__.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/cli.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/config.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/connectors/__init__.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/connectors/base.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/connectors/powerbi.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/connectors/tableau.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/core/__init__.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/core/cube_generator.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/core/dbt_parser.py +0 -0
- {dbt_cube_sync-0.1.0a3 → dbt_cube_sync-0.1.0a4}/dbt_cube_sync/core/models.py +0 -0
|
@@ -337,12 +337,26 @@ class SupersetConnector(BaseConnector):
|
|
|
337
337
|
'count_distinct': 'COUNT(DISTINCT'
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
# Remove Cube.js ${} syntax and convert to plain SQL column references
|
|
341
|
+
cleaned_expression = self._clean_cube_expression(sql_expression)
|
|
342
|
+
|
|
340
343
|
agg_func = agg_mapping.get(agg_type, 'SUM')
|
|
341
344
|
|
|
342
345
|
if agg_type == 'count_distinct':
|
|
343
|
-
return f"{agg_func} {
|
|
346
|
+
return f"{agg_func} {cleaned_expression})"
|
|
344
347
|
else:
|
|
345
|
-
return f"{agg_func}({
|
|
348
|
+
return f"{agg_func}({cleaned_expression})"
|
|
349
|
+
|
|
350
|
+
def _clean_cube_expression(self, expression: str) -> str:
|
|
351
|
+
"""Convert Cube.js expressions to SQL column references for Superset"""
|
|
352
|
+
import re
|
|
353
|
+
|
|
354
|
+
# Remove ${} syntax - convert ${column_name} to column_name
|
|
355
|
+
cleaned = re.sub(r'\$\{([^}]+)\}', r'\1', expression)
|
|
356
|
+
|
|
357
|
+
# Handle more complex expressions like arithmetic
|
|
358
|
+
# Keep parentheses and operators but clean column references
|
|
359
|
+
return cleaned
|
|
346
360
|
|
|
347
361
|
def _create_or_update_dataset(self, schema_info: Dict[str, Any]) -> int:
|
|
348
362
|
"""Create a new dataset or update existing one"""
|
|
@@ -506,37 +520,41 @@ class SupersetConnector(BaseConnector):
|
|
|
506
520
|
|
|
507
521
|
def _update_metrics(self, existing_metrics: List[dict], measures: List[dict]) -> List[dict]:
|
|
508
522
|
"""Update metrics with new measures"""
|
|
509
|
-
# Clean existing metrics
|
|
523
|
+
# Clean existing metrics and create a lookup by name
|
|
510
524
|
updated_metrics = []
|
|
525
|
+
existing_metric_names = {}
|
|
526
|
+
|
|
511
527
|
for metric in existing_metrics:
|
|
512
528
|
clean_metric = {k: v for k, v in metric.items()
|
|
513
529
|
if k not in ['created_on', 'changed_on', 'uuid']}
|
|
530
|
+
existing_metric_names[metric.get('metric_name')] = len(updated_metrics)
|
|
514
531
|
updated_metrics.append(clean_metric)
|
|
515
532
|
|
|
516
|
-
# Add
|
|
517
|
-
existing_metric_names = {m.get('metric_name') for m in existing_metrics}
|
|
518
|
-
added_count = 0
|
|
519
|
-
|
|
533
|
+
# Add or update metrics
|
|
520
534
|
for measure in measures:
|
|
521
535
|
metric_name = measure['metric_name']
|
|
522
536
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
537
|
+
new_metric = {
|
|
538
|
+
'metric_name': metric_name,
|
|
539
|
+
'verbose_name': measure['verbose_name'],
|
|
540
|
+
'expression': measure['expression'],
|
|
541
|
+
'description': measure['description'],
|
|
542
|
+
'metric_type': 'simple',
|
|
543
|
+
'currency': None,
|
|
544
|
+
'd3format': None,
|
|
545
|
+
'extra': None,
|
|
546
|
+
'warning_text': None
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if metric_name in existing_metric_names:
|
|
550
|
+
# Update existing metric
|
|
551
|
+
index = existing_metric_names[metric_name]
|
|
552
|
+
updated_metrics[index].update(new_metric)
|
|
553
|
+
print(f" ✓ Updated '{metric_name}': {measure['expression']}")
|
|
538
554
|
else:
|
|
539
|
-
|
|
555
|
+
# Add new metric
|
|
556
|
+
updated_metrics.append(new_metric)
|
|
557
|
+
print(f" ✓ Added '{metric_name}': {measure['expression']}")
|
|
540
558
|
|
|
541
559
|
return updated_metrics
|
|
542
560
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|