Laminar SQL Editor is a tool that allows you to write and execute SQL queries on your data stored at Laminar.

The main use cases for this are:

  • Advanced analytics on your data
  • Exporting any trace or evaluation result to a dataset

The SQL Editor is currently in beta. Some functionality may change. We value your feedback and suggestions.

Laminar provides some useful syntactic sugar over standard PostgreSQL so that you don’t have to write explicit joins and you don’t depend on our internal data model too much.

For detailed reference of the syntax, see the reference page.

Features and benefits

  • Write and execute SQL queries on your data stored at Laminar
  • Filtering:
    • By date range
    • By span name and path
    • By span tags
    • By trace costs, metadata, duration, etc.
    • By evaluator scores
    • By evaluation results
  • Fast analytics on your data, e.g.
    • Detailed breakdown of token count and cost by operation
    • Detailed latency analysis
  • Exporting results to Laminar datasets or labelling queues

Allowed queries and limitations

  • Only SELECT queries are allowed.
  • Allowed tables (to select from):
    • spans
    • traces
    • evaluation_results
    • evaluation_scores
    • evaluations
    • datasets
    • dataset_datapoints
  • Currently, adding WITH CTEs is not supported.

For detailed information about the tables and columns, see the reference page.

Getting started

Prerequisites

  • You must have some data stored at Laminar, such as traces, evaluation results, or datasets.

Using the SQL Editor

In any page in your dashboard, click the Terminal icon in the top right corner.

You will see a sheet with an SQL editor.

Example query

SELECT
    input,
    output,
    start_time
FROM spans
WHERE start_time BETWEEN now() - INTERVAL '3 days' AND now()

This query will return the input and output of the spans in the last 3 days.

For more examples, see the examples page.

Viewing results

Results are displayed in a table or raw JSON view.

Exporting results

Once you have selected the results you want to export, click the “Export to Dataset” button.

Choose the dataset you want to export to and map the columns to the dataset data, metadata, and target fields.

Learn more about datasets

Next steps

  • Examples – Examples of SQL queries you can write with the Laminar SQL Editor
  • Reference – Reference of the table schemas and Laminar-specific syntax