Skip to content

Commit 5548c47

Browse files
author
Alison Gim
committed
Move extend clause after summarize for calculated measures
This ensures that extend operations (which may reference summarized columns) are executed after the summarize clause in the generated KQL query.
1 parent b8acb7a commit 5548c47

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sqlalchemy_kusto/dialect_kql.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,15 @@ def visit_select(
142142
)
143143
compiled_query_lines.append(f"| where {converted_where_clause}")
144144

145+
# Add summarize first if it exists
146+
if "summarize" in projections_parts_dict:
147+
compiled_query_lines.append(projections_parts_dict.pop("summarize"))
148+
149+
# Then add extend after summarize
145150
if "extend" in projections_parts_dict:
146151
compiled_query_lines.append(projections_parts_dict.pop("extend"))
147152

153+
# Add remaining parts (project, sort)
148154
for statement_part in projections_parts_dict.values():
149155
if statement_part:
150156
compiled_query_lines.append(statement_part)

0 commit comments

Comments
 (0)