SQL Editor Reference
Reference of the table schemas and Laminar-specific syntax
This page contains a reference of the table schemas and Laminar-specific syntax. For examples of SQL queries you can write with the Laminar SQL Editor, see the examples page.
Table schemas and enum types
This section contains subsets of the table schemas and enumerated_types that are relevant to the SQL Editor.
spans
traces
datasets
dataset_datapoints
evaluations
evaluation_results
trace_type enum
span_type enum
DEFAULT
- most of the spans fall into this categoryLLM
- a manual or automatically traced LLM callEVALUATION
- a span that represents an evaluation run. One datapoint is evaluated by one evaluation run.EXECUTOR
- a span that represents an executor run. One datapoint is evaluated by one executor run.EVALUATOR
- a span that represents an evaluator run. One datapoint may have multiple evaluator spans.TOOL
- a span that represents a tool call.
Laminar-specific syntax
"spans"."path"
Span path is the hierarchical path of the span.
For example, if your code looks like this:
Then the span path of the inner
function will be ["outer", "inner"]
.
However, Laminar SQL provides syntactic sugar for you to query, filter, order, or group by span path
items joined by a dot. That is, you can write WHERE path = 'outer.inner'
instead of WHERE attributes->'path' = '["outer", "inner"]'::jsonb
.
evaluator_scores
Evaluator scores is a virtual table CTE that allows you to quickly filter spans by their evaluator scores.
This is triggered only when you select from spans
table.
For example, if you have an evaluator named "Task alignment"
that scores between 0 and 1,
you can write WHERE evaluator_scores."Task alignment" > 0.5
to filter spans by their evaluator scores.
For example,
evaluation_scores
Evaluation scores is a virtual table CTE that allows you to quickly filter evaluation results by their scores.
This is triggered only when you select from evaluation_results
table.
For example, if you have an evaluator named “My Score” that scores between 0 and 1,
you can write WHERE evaluation_scores."My Score" > 0.5
to filter evaluation results by their evaluator scores.
For example,
evaluation_name
and evaluation_id
in traces
and spans
tables
evaluation_name
and evaluation_id
are virtual columns that are automatically populated by the SQL Editor.
This sugar joins in the following way:
This is triggered when you select evaluation_name
or evaluation_id
in the traces
or spans
tables.
tag
in the spans
table
If your span has tags my_tag
and my_other_tag
, you can write WHERE tag = 'my_tag'
to filter spans by their tags.
This is triggered when you select tag
in the spans
table.
Trace details in the evaluation_results
table
Each evaluation result is associated with a trace. You can query the following
trace details directly from the evaluation_results
table:
cost
total_token_count
start_time
end_time
duration
(Learn more)
Duration
Duration is the time taken to execute the evaluation.
It is calculated as end_time - start_time
in seconds.
Whenever you query duration
in the evaluation_results
table or the traces
table, the SQL Editor will automatically
replace that with EXTRACT(EPOCH FROM end_time - start_time)
.
Indexing considerations
Spans table is better indexed on start_time
than created_at
.
We will add more indexes as we see emerging usage patterns from the SQL Editor.