Claude Opus4 fails when executing the query:
Request
{
`query`: `
-- Check the year range and total records in the dataset
SELECT
min(Year) as min_year,
max(Year) as max_year,
count(*) as total_flights,
formatReadableQuantity(count(*)) as readable_count
FROM default.ontime
LIMIT 1
`
}
Response
[{"type": "text", "text":
"{\n \"columns\": [\n \"status\"\n ],\n \"types\": [\n \"String\"\n ],\n
\"rows\": [\n [\n \"OK\"\n ]\n ],\n \"count\": 1\n}",
"uuid": "5c6d6151-0409-4452-8c0a-3086bc7e748b"}]
Let me fix the query:
As a result, it tries to rewrite the query somewhere else in many steps, taking time and tokens.
Seems that the problem is in wrong SELECT/non-SELECT query classification on queries started from comment:
// isSelectQuery determines if a query is a SELECT query
func isSelectQuery(query string) bool {
// Simple check - can be improved with more sophisticated parsing if needed
trimmed := strings.TrimSpace(strings.ToUpper(query))
return strings.HasPrefix(trimmed, "SELECT") || strings.HasPrefix(trimmed, "WITH")
}
// For non-SELECT queries, we just return an empty result with success status
result.Columns = []string{"status"}
result.Types = []string{"String"}
result.Rows = [][]interface{}{{"OK"}}
Clickhouse supports two types of SL comments: -- and /* */. Both should be supported.
Claude Opus4 fails when executing the query:
As a result, it tries to rewrite the query somewhere else in many steps, taking time and tokens.
Seems that the problem is in wrong SELECT/non-SELECT query classification on queries started from comment:
Clickhouse supports two types of SL comments: -- and /* */. Both should be supported.