Conversation
📝 WalkthroughWalkthroughA new query enrichment module extracts the enrichment phase from the query engine, transforming SlayerQuery into EnrichedQuery while handling dimension/join resolution, filter classification, and cross-model measure support. Supporting code is refactored to delegate enrichment and align terminology from "rollup" to "joins". Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~55 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
slayer/engine/enrichment.py (1)
459-464: Substring match could produce false positives in edge cases.The time dimension name lookup uses a simple substring check (
if td_name in f_str), which could match unintended occurrences (e.g., dimension"at"matching within"status").This is a fallback heuristic only triggered when no explicit time dimension is provided, so the impact is limited. Consider using word boundaries if this causes issues in practice:
♻️ Optional: Use word-boundary matching
if query.filters: time_dim_names = {d.name for d in model.dimensions if d.type in (DataType.TIMESTAMP, DataType.DATE)} for f_str in query.filters or []: for td_name in time_dim_names: - if td_name in f_str: + if re.search(rf"\b{re.escape(td_name)}\b", f_str): return f"{model.name}.{td_name}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@slayer/engine/enrichment.py` around lines 459 - 464, The current heuristic inspects filters with a substring check (`if td_name in f_str`) which can produce false positives (e.g., matching "at" inside "status"); replace this with a whole-word match using word-boundary regex or tokenization so you only match complete dimension identifiers: in the block that computes time_dim_names from model.dimensions and iterates query.filters, use a compiled regex like r'\b{td_name}\b' (with proper escaping) or split tokens to test membership, and ensure you import/prepare the regex beforehand and use it in place of the substring check so return f"{model.name}.{td_name}" only on true whole-word matches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@slayer/engine/enrichment.py`:
- Around line 459-464: The current heuristic inspects filters with a substring
check (`if td_name in f_str`) which can produce false positives (e.g., matching
"at" inside "status"); replace this with a whole-word match using word-boundary
regex or tokenization so you only match complete dimension identifiers: in the
block that computes time_dim_names from model.dimensions and iterates
query.filters, use a compiled regex like r'\b{td_name}\b' (with proper escaping)
or split tokens to test membership, and ensure you import/prepare the regex
beforehand and use it in place of the substring check so return
f"{model.name}.{td_name}" only on true whole-word matches.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 14c550a9-22eb-4b87-b4b9-40b40c053362
📒 Files selected for processing (6)
examples/embedded/verify.pyexamples/seed.pyexamples/verify_common.pyslayer/engine/enrichment.pyslayer/engine/query_engine.pytests/test_sql_generator.py
Summary by CodeRabbit
Release Notes
Refactor
Documentation
Tests