Skip to content

Commit 07e2ddf

Browse files
committed
docs: shorten table resolution comments
Signed-off-by: mday-io <mdaytn@gmail.com>
1 parent 2ee0fed commit 07e2ddf

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

sqlmesh/core/renderer.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,31 +332,19 @@ def _resolve_table(
332332
) -> exp.Table:
333333
table_mapping = table_mapping or {}
334334
if isinstance(table_name, str):
335-
# table_name arrives here already normalized to a model FQN (see the `resolve_table`
336-
# closure below and the `this_model` call site), the same key format `snapshots` and
337-
# `table_mapping` use. Only the one relevant snapshot needs mapping, not the whole
338-
# environment - building the full mapping made this call O(N) in the number of
339-
# snapshots in the environment for every table resolved.
335+
# An exact FQN match avoids scanning unrelated snapshots.
340336
snapshot = snapshots.get(table_name) if snapshots else None
341337
if snapshot is None and table_name not in table_mapping:
342-
# table_name is normalized under this renderer's own dialect, but a snapshots key
343-
# is normalized under that model's own dialect and a table_mapping key may come
344-
# from yet another dialect (e.g. a test fixture's table_mapping, normalized under
345-
# the project's dialect) - these can disagree in casing/quoting even though an
346-
# entry for this table exists in one of them. A direct dict lookup can miss in
347-
# that case, so on a miss in both dicts, fall back to the full, dialect-
348-
# reconciling mapping that exp.replace_tables itself performs. This only pays the
349-
# O(N) cost on a miss, not on every resolution.
338+
# Keys normalized under different dialects may differ in casing or quoting.
339+
# Fall back to the full mapping so exp.replace_tables can reconcile them.
350340
mapping = {
351341
**self._to_table_mapping((snapshots or {}).values(), deployability_index),
352342
**table_mapping,
353343
}
354344
else:
355345
mapping = {
356346
**self._to_table_mapping([snapshot] if snapshot else [], deployability_index),
357-
# Keep the complete explicit mapping so exp.replace_tables can preserve
358-
# its dialect-aware matching and precedence for equivalent keys. This still
359-
# avoids scanning the full snapshots environment.
347+
# Keep all explicit overrides to preserve precedence for equivalent keys.
360348
**table_mapping,
361349
}
362350
else:

0 commit comments

Comments
 (0)