Skip to content

Commit d020dc3

Browse files
committed
Include default catalog in model names if very verbose
1 parent 5698441 commit d020dc3

2 files changed

Lines changed: 48 additions & 27 deletions

File tree

sqlmesh/core/console.py

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,9 @@ def start_evaluation_progress(
643643
def start_snapshot_evaluation_progress(self, snapshot: Snapshot) -> None:
644644
if self.evaluation_model_progress and snapshot.name not in self.evaluation_model_tasks:
645645
display_name = snapshot.display_name(
646-
self.environment_naming_info, self.default_catalog, dialect=self.dialect
646+
self.environment_naming_info,
647+
self.default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
648+
dialect=self.dialect,
647649
)
648650
self.evaluation_model_tasks[snapshot.name] = self.evaluation_model_progress.add_task(
649651
f"Evaluating {display_name}...",
@@ -749,7 +751,7 @@ def update_creation_progress(self, snapshot: SnapshotInfoLike) -> None:
749751
if self.creation_progress is not None and self.creation_task is not None:
750752
if self.verbosity >= Verbosity.VERBOSE:
751753
self.creation_progress.live.console.print(
752-
f"{GREEN_CHECK_MARK} {snapshot.display_name(self.environment_naming_info, self.default_catalog, dialect=self.dialect)} [green]created[/green]"
754+
f"{GREEN_CHECK_MARK} {snapshot.display_name(self.environment_naming_info, self.default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} [green]created[/green]"
753755
)
754756
self.creation_progress.update(self.creation_task, refresh=True, advance=1)
755757

@@ -827,7 +829,7 @@ def update_promotion_progress(self, snapshot: SnapshotInfoLike, promoted: bool)
827829
check_mark = f"{GREEN_CHECK_MARK} " if promoted else " "
828830
action_str = "[green]updated[/green]" if promoted else "[yellow]demoted[/yellow]"
829831
self.promotion_progress.live.console.print(
830-
f"{check_mark}{snapshot.display_name(self.environment_naming_info, self.default_catalog, dialect=self.dialect)} {action_str}"
832+
f"{check_mark}{snapshot.display_name(self.environment_naming_info, self.default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} {action_str}"
831833
)
832834
self.promotion_progress.update(self.promotion_task, refresh=True, advance=1)
833835

@@ -1044,15 +1046,15 @@ def _show_summary_tree_for(
10441046
for s_id in sorted(added_snapshot_ids):
10451047
snapshot = context_diff.snapshots[s_id]
10461048
added_tree.add(
1047-
f"[added]{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}"
1049+
f"[added]{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
10481050
)
10491051
tree.add(self._limit_model_names(added_tree, self.verbosity))
10501052
if removed_snapshot_ids:
10511053
removed_tree = Tree("[bold][removed]Removed:")
10521054
for s_id in sorted(removed_snapshot_ids):
10531055
snapshot_table_info = context_diff.removed_snapshots[s_id]
10541056
removed_tree.add(
1055-
f"[removed]{snapshot_table_info.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}"
1057+
f"[removed]{snapshot_table_info.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
10561058
)
10571059
tree.add(self._limit_model_names(removed_tree, self.verbosity))
10581060
if modified_snapshot_ids:
@@ -1062,7 +1064,9 @@ def _show_summary_tree_for(
10621064
for s_id in modified_snapshot_ids:
10631065
name = s_id.name
10641066
display_name = context_diff.snapshots[s_id].display_name(
1065-
environment_naming_info, default_catalog, dialect=self.dialect
1067+
environment_naming_info,
1068+
default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
1069+
dialect=self.dialect,
10661070
)
10671071
if context_diff.directly_modified(name):
10681072
direct.add(
@@ -1139,7 +1143,7 @@ def _prompt_categorize(
11391143
if not no_diff:
11401144
self.show_sql(plan.context_diff.text_diff(snapshot.name))
11411145
tree = Tree(
1142-
f"[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)}"
1146+
f"[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
11431147
)
11441148
indirect_tree = None
11451149

@@ -1149,7 +1153,7 @@ def _prompt_categorize(
11491153
indirect_tree = Tree("[indirect]Indirectly Modified Children:")
11501154
tree.add(indirect_tree)
11511155
indirect_tree.add(
1152-
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)}"
1156+
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
11531157
)
11541158
if indirect_tree:
11551159
indirect_tree = self._limit_model_names(indirect_tree, self.verbosity)
@@ -1167,7 +1171,7 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
11671171
if context_diff.directly_modified(snapshot.name):
11681172
category_str = SNAPSHOT_CHANGE_CATEGORY_STR[snapshot.change_category]
11691173
tree = Tree(
1170-
f"\n[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)} ({category_str})"
1174+
f"\n[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} ({category_str})"
11711175
)
11721176
indirect_tree = None
11731177
for child_sid in sorted(plan.indirectly_modified.get(snapshot.snapshot_id, set())):
@@ -1179,13 +1183,13 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
11791183
child_snapshot.change_category
11801184
]
11811185
indirect_tree.add(
1182-
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)} ({child_category_str})"
1186+
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} ({child_category_str})"
11831187
)
11841188
if indirect_tree:
11851189
indirect_tree = self._limit_model_names(indirect_tree, self.verbosity)
11861190
elif context_diff.metadata_updated(snapshot.name):
11871191
tree = Tree(
1188-
f"\n[bold][metadata]Metadata Updated: {snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)}"
1192+
f"\n[bold][metadata]Metadata Updated: {snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
11891193
)
11901194
else:
11911195
continue
@@ -1212,7 +1216,9 @@ def _show_missing_dates(self, plan: Plan, default_catalog: t.Optional[str]) -> N
12121216
preview_modifier = " ([orange1]preview[/orange1])"
12131217

12141218
display_name = snapshot.display_name(
1215-
plan.environment_naming_info, default_catalog, dialect=self.dialect
1219+
plan.environment_naming_info,
1220+
default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
1221+
dialect=self.dialect,
12161222
)
12171223
backfill.add(
12181224
f"{display_name}: \\[{_format_missing_intervals(snapshot, missing)}]{preview_modifier}"
@@ -1610,7 +1616,9 @@ def _snapshot_change_choices(
16101616
use_rich_formatting: bool = True,
16111617
) -> t.Dict[SnapshotChangeCategory, str]:
16121618
direct = snapshot.display_name(
1613-
environment_naming_info, default_catalog, dialect=self.dialect
1619+
environment_naming_info,
1620+
default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
1621+
dialect=self.dialect,
16141622
)
16151623
if use_rich_formatting:
16161624
direct = f"[direct]{direct}[/direct]"
@@ -2079,15 +2087,15 @@ def show_model_difference_summary(
20792087
else:
20802088
for snapshot in added_models:
20812089
self._print(
2082-
f"- `{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2090+
f"- `{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
20832091
)
20842092

20852093
added_snapshot_audits = {s for s in added_snapshots if s.is_audit}
20862094
if added_snapshot_audits:
20872095
self._print("\n**Added Standalone Audits:**")
20882096
for snapshot in sorted(added_snapshot_audits):
20892097
self._print(
2090-
f"- `{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2098+
f"- `{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
20912099
)
20922100

20932101
removed_snapshot_table_infos = set(context_diff.removed_snapshots.values())
@@ -2106,15 +2114,15 @@ def show_model_difference_summary(
21062114
else:
21072115
for snapshot_table_info in removed_models:
21082116
self._print(
2109-
f"- `{snapshot_table_info.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2117+
f"- `{snapshot_table_info.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21102118
)
21112119

21122120
removed_audit_snapshot_table_infos = {s for s in removed_snapshot_table_infos if s.is_audit}
21132121
if removed_audit_snapshot_table_infos:
21142122
self._print("\n**Removed Standalone Audits:**")
21152123
for snapshot_table_info in sorted(removed_audit_snapshot_table_infos):
21162124
self._print(
2117-
f"- `{snapshot_table_info.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2125+
f"- `{snapshot_table_info.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21182126
)
21192127

21202128
modified_snapshots = {
@@ -2135,7 +2143,7 @@ def show_model_difference_summary(
21352143
self._print("\n**Directly Modified:**")
21362144
for snapshot in sorted(directly_modified):
21372145
self._print(
2138-
f"- `{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2146+
f"- `{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21392147
)
21402148
if not no_diff:
21412149
self._print(f"```diff\n{context_diff.text_diff(snapshot.name)}\n```")
@@ -2148,20 +2156,20 @@ def show_model_difference_summary(
21482156
and modified_length > self.INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
21492157
):
21502158
self._print(
2151-
f"- `{indirectly_modified[0].display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`\n"
2159+
f"- `{indirectly_modified[0].display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`\n"
21522160
f"- `.... {modified_length-2} more ....`\n"
2153-
f"- `{indirectly_modified[-1].display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2161+
f"- `{indirectly_modified[-1].display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21542162
)
21552163
else:
21562164
for snapshot in indirectly_modified:
21572165
self._print(
2158-
f"- `{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2166+
f"- `{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21592167
)
21602168
if metadata_modified:
21612169
self._print("\n**Metadata Updated:**")
21622170
for snapshot in sorted(metadata_modified):
21632171
self._print(
2164-
f"- `{snapshot.display_name(environment_naming_info, default_catalog, dialect=self.dialect)}`"
2172+
f"- `{snapshot.display_name(environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}`"
21652173
)
21662174

21672175
def _show_missing_dates(self, plan: Plan, default_catalog: t.Optional[str]) -> None:
@@ -2181,7 +2189,9 @@ def _show_missing_dates(self, plan: Plan, default_catalog: t.Optional[str]) -> N
21812189
preview_modifier = " (**preview**)"
21822190

21832191
display_name = snapshot.display_name(
2184-
plan.environment_naming_info, default_catalog, dialect=self.dialect
2192+
plan.environment_naming_info,
2193+
default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
2194+
dialect=self.dialect,
21852195
)
21862196
snapshots.append(
21872197
f"* `{display_name}`: [{_format_missing_intervals(snapshot, missing)}]{preview_modifier}"
@@ -2205,7 +2215,7 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
22052215
if context_diff.directly_modified(snapshot.name):
22062216
category_str = SNAPSHOT_CHANGE_CATEGORY_STR[snapshot.change_category]
22072217
tree = Tree(
2208-
f"[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)} ({category_str})"
2218+
f"[bold][direct]Directly Modified: {snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} ({category_str})"
22092219
)
22102220
indirect_tree = None
22112221
for child_sid in sorted(plan.indirectly_modified.get(snapshot.snapshot_id, set())):
@@ -2217,13 +2227,13 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
22172227
child_snapshot.change_category
22182228
]
22192229
indirect_tree.add(
2220-
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)} ({child_category_str})"
2230+
f"[indirect]{child_snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)} ({child_category_str})"
22212231
)
22222232
if indirect_tree:
22232233
indirect_tree = self._limit_model_names(indirect_tree, self.verbosity)
22242234
elif context_diff.metadata_updated(snapshot.name):
22252235
tree = Tree(
2226-
f"[bold][metadata]Metadata Updated: {snapshot.display_name(plan.environment_naming_info, default_catalog, dialect=self.dialect)}"
2236+
f"[bold][metadata]Metadata Updated: {snapshot.display_name(plan.environment_naming_info, default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None, dialect=self.dialect)}"
22272237
)
22282238
else:
22292239
continue
@@ -2328,7 +2338,9 @@ def start_evaluation_progress(
23282338
def start_snapshot_evaluation_progress(self, snapshot: Snapshot) -> None:
23292339
if not self.evaluation_batch_progress.get(snapshot.snapshot_id):
23302340
display_name = snapshot.display_name(
2331-
self.evaluation_environment_naming_info, self.default_catalog, dialect=self.dialect
2341+
self.evaluation_environment_naming_info,
2342+
self.default_catalog if self.verbosity < Verbosity.VERY_VERBOSE else None,
2343+
dialect=self.dialect,
23322344
)
23332345
self.evaluation_batch_progress[snapshot.snapshot_id] = (display_name, 0)
23342346
print(

sqlmesh/core/snapshot/definition.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,15 @@ def display_name(
15591559
Returns the model name as a qualified view name.
15601560
This is just used for presenting information back to the user and `qualified_view_name` should be used
15611561
when wanting a view name in all other cases.
1562+
1563+
Args:
1564+
snapshot_info_like: The snapshot info object to get the display name for
1565+
environment_naming_info: Environment naming info to use for display name formatting
1566+
default_catalog: Optional default catalog name to use. If None, the default catalog will always be included in the display name.
1567+
dialect: Optional dialect type to use for name formatting
1568+
1569+
Returns:
1570+
The formatted display name as a string
15621571
"""
15631572
if snapshot_info_like.is_audit:
15641573
return snapshot_info_like.name

0 commit comments

Comments
 (0)