# Trino

Marple integrates seamlessly with [Trino](https://trino.io/), a fast distributed SQL query engine.

What makes this connection particularly powerful is that Trino itself supports a wide range of underlying data sources, making all of them accessible through Insight as well.

### Required credentials

To connect, the following credentials are needed:

* Host
* User
* Password
* Port

### Queries

Queries are executed using SQL. Marple offers predefined queries for fetching datasets, signals, and time-series data. Below are some example queries:

* To retrieve **datasets**:

```sql
select
    concat("carId", ' ', session) as display_name,
    "carId",
    event,
    session,
    min(time) as start,
    max(time) as stop,
    realtime
  from {{TABLE}}
  group by "carId", event, session, realtime
```

* To retrieve a **signal list:**

```sql
select 
  name,
  sum(count) as count,
  CAST(max(count) AS double) * 1e9 AS frequency,
  unit,
  description
from {{TABLE}}
where "carId" = '{{ dataset.carId }}'
group by name
```

* To retrieve the **time series data**

```sql
select time / 1e9 as "timestamp", value
from {{TABLE}}
where "carId" = '{{ dataset.carId }}'
{%- if timestamp_start %}
and CAST({{timestamp_start}} AS BIGINT) * 1e9 <= time
{%- endif %}
{%- if timestamp_stop %}
and CAST({{timestamp_stop}} AS BIGINT)  * 1e9 >= time
{%- endif %}
and name = '{{ signal.name }}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.marpledata.com/docs/marple-insight/setup-and-configuration/data-connection/supported-databases/trino.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
