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.
create table spans ( span_id uuid not null, created_at timestamp with time zone not null default now(), parent_span_id uuid null, name text not null, attributes jsonb null, input jsonb null, output jsonb null, span_type span_type not null, start_time timestamp with time zone not null, end_time timestamp with time zone not null, trace_id uuid not null, status text null, constraint spans_trace_id_fkey foreign KEY (trace_id) references traces (id));
create table traces ( id uuid not null default gen_random_uuid (), session_id text null, metadata jsonb null, end_time timestamp with time zone null, start_time timestamp with time zone null, total_token_count bigint not null default '0'::bigint, cost double precision not null default '0'::double precision, created_at timestamp with time zone not null default now(), trace_type trace_type not null default 'DEFAULT'::trace_type, input_token_count bigint not null default '0'::bigint, output_token_count bigint not null default '0'::bigint, input_cost double precision not null default '0'::double precision, output_cost double precision not null default '0'::double precision, top_span_id uuid null, -- soft references spans.span_id status text null, -- this is not your user ID, but the user ID you've sent with the trace user_id text null, constraint traces_pkey primary key (id));
create table datasets ( id uuid not null default gen_random_uuid (), created_at timestamp with time zone not null default now(), name text not null, constraint datasets_pkey primary key (id));
create table evaluations ( id uuid not null default gen_random_uuid (), created_at timestamp with time zone not null default now(), name text not null, group_id text not null default 'default'::text, constraint evaluations_pkey primary key (id),);
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 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,
Copy
-- note that you don't need to join anything else,-- the SQL Editor will do the necessary joins for youSELECT name, input, output, evaluator_scores."Task alignment"FROM spansWHERE evaluator_scores."Task alignment" > 0.5
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,
Copy
-- note that you don't need to join anything else,-- the SQL Editor will do the necessary joins for youSELECT id, index, duration, evaluation_scores."My Score"FROM evaluation_resultsWHERE evaluation_scores."My Score" >= 0
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).