From d5952652705ba3d018bf0b08bcfcd98d321e663a Mon Sep 17 00:00:00 2001 From: EAWRCEQA Date: Tue, 21 Jul 2026 04:17:40 +0800 Subject: [PATCH] fix: avoid excluding measurement fields whose names contain "id" _detect_metric_field skipped any numeric field whose lowercased name contained the substring "id", which unintentionally matched common measurement columns such as width, humidity, grid_load and candidate_count. These aggregatable metrics were dropped from the auto-generated semantic layer on data upload. Match "id"/"_id" precisely (standalone name or _id suffix), mirroring the existing _detect_id_field logic, so real ID columns (id, vehicle_id, user_id) are still excluded. --- agentic_core/schema_inference.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agentic_core/schema_inference.py b/agentic_core/schema_inference.py index 0b98e7a..7f9b007 100644 --- a/agentic_core/schema_inference.py +++ b/agentic_core/schema_inference.py @@ -92,8 +92,12 @@ def _detect_metric_field(field_name, field_type, values): if field_type not in ("integer", "float"): return False name_lower = field_name.lower() - # Skip ID-like numeric fields - if any(p in name_lower for p in ["_id", "id", "code", "编号", "year", "月", "日"]): + # Skip ID-like numeric fields. Match "id"/"_id" precisely (standalone name + # or "_id" suffix) instead of as a substring, otherwise measurement fields + # such as "width", "humidity" or "grid_load" are wrongly excluded. + if name_lower == "id" or name_lower.endswith("_id"): + return False + if any(p in name_lower for p in ["code", "编号", "year", "月", "日"]): return False return True