Skip to content

Commit 4f2ccc9

Browse files
committed
Add SQL guideline for DISTINCT with ORDER BY limitation; fix formatting in error message
1 parent 9695a5b commit 4f2ccc9

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/data_agent/config/amex.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ data_agents:
7373
7. **Use LIMIT** to restrict results (e.g., LIMIT 100) unless the user specifies otherwise.
7474
8. **Handle NULL values** appropriately with IFNULL, COALESCE, or IS NOT NULL checks.
7575
9. **Use fully qualified table names** in format `project.dataset.table` or just `dataset.table`.
76+
10. **DISTINCT with ORDER BY limitation**: When using DISTINCT inside aggregate functions (e.g., ARRAY_AGG, STRING_AGG), ORDER BY can only reference the column being aggregated, not other columns.
7677
7778
## Response Format
7879

‎src/data_agent/nodes/data_nodes.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ async def retry_sql(self, state: "AgentState") -> dict[str, Any]:
388388
"retry_count": retry_count,
389389
"messages": [
390390
HumanMessage(
391-
content=f"Error: {error}\n\nPlease fix the query.", name="sql_validator"
391+
content=f"Error: {error}\n\nPlease fix the query.",
392+
name="sql_validator",
392393
),
393394
AIMessage(content=f"```sql\n{cleaned}\n```", name="sql_generator"),
394395
],

0 commit comments

Comments
 (0)