Bug
The --sessions command in scripts/braintrust_analyze.py fails with a SQL parse error:
SQL Error: 400 - Expected: end of statement, found: ( at Line: 7, Column: 29
Cause
The list_sessions() function (line 332) uses PostgreSQL's COUNT(*) FILTER (WHERE ...) syntax, which BTQL does not support.
COUNT(*) FILTER (WHERE span_attributes['type'] = 'tool') as tool_count
Fix
Replace with standard SQL SUM(CASE WHEN ... END):
SUM(CASE WHEN span_attributes['type'] = 'tool' THEN 1 ELSE 0 END) as tool_count
Tested and confirmed working against the Braintrust API.
Bug
The
--sessionscommand inscripts/braintrust_analyze.pyfails with a SQL parse error:Cause
The
list_sessions()function (line 332) uses PostgreSQL'sCOUNT(*) FILTER (WHERE ...)syntax, which BTQL does not support.Fix
Replace with standard SQL
SUM(CASE WHEN ... END):Tested and confirmed working against the Braintrust API.