Skip to main content

Documentation Index

Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Applies to:
  • Plan -
  • Deployment -

Summary

Issue: Queries fail with a Field not found error when a subquery’s table alias matches a column name used inside the subquery. Cause: The alias collides with the column of the same name, causing Braintrust SQL to fail resolving field references without indicating the naming conflict. Resolution: Rename the subquery alias to a value that does not match any column name referenced in the query.

Resolution steps

If you see Field not found with a subquery alias

Step 1: Check for alias/column name collisions

Compare the alias assigned to your subquery against the column names inside it. A match between the alias and a column name causes the error.
-- Fails: alias 'metrics' conflicts with column 'metrics'
SELECT metric AS name, AVG(value)
FROM (
  SELECT metric, value
  FROM experiment('724d08ca-d04e-4a40-8dd7-ad52498cdea3')
  UNPIVOT (value FOR metric IN (metrics))
) AS metrics
WHERE name IS NOT NULL
GROUP BY name

Step 2: Rename the subquery alias

Change the alias to a value that does not match any column name in the subquery.
-- Works: alias 'unpivoted' does not conflict with any column name
SELECT metric AS name, AVG(value)
FROM (
  SELECT metric, value
  FROM experiment('724d08ca-d04e-4a40-8dd7-ad52498cdea3')
  UNPIVOT (value FOR metric IN (metrics))
) AS unpivoted
WHERE name IS NOT NULL
GROUP BY name

Otherwise, if the error persists after renaming

Check all aliases in the query scope

Review every alias in the query — including column aliases and outer query references — to ensure none conflict with column names produced by any subquery.

Contact support

If no naming conflict is found and the error continues, contact Braintrust support with your full query and the experiment ID for investigation.