Skip to content

Commit 2a7efb3

Browse files
committed
Trino: Implement suggestions by CodeRabbit
1 parent 7da2637 commit 2a7efb3

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

docs/feature/query/index.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ set of built-in functions.
2222

2323
::::{grid-item}
2424
:columns: auto 9 9 9
25-
**Analyzing Device Readings**
25+
**Analyze Device Readings**
2626

2727
Effectively query measurement readings using enhanced features for time series data.
2828

@@ -114,7 +114,7 @@ ORDER BY 1 DESC;
114114
## Aggregations
115115
Fast aggregations, even with complex queries.
116116
- {ref}`aggregations`
117-
- [Analyzing Device Readings with Metadata Integration]
117+
- [Analyze Device Readings with Metadata Integration]
118118

119119
## Bulk Operations
120120

@@ -132,7 +132,7 @@ The advantages are:
132132
(cte)=
133133
(ctes)=
134134
## CTEs
135-
[Time Series: Analyzing Weather Data]
135+
[Time Series: Analyze Weather Data]
136136

137137

138138
(hyperloglog)=
@@ -154,8 +154,8 @@ https://community.cratedb.com/t/advanced-downsampling-with-the-lttb-algorithm/12
154154

155155
(maximum-minimum)=
156156
## Maximum/Minimum Values
157-
- [Analyzing Device Readings with Metadata Integration]
158-
- [Time Series: Analyzing Weather Data]
157+
- [Analyze Device Readings with Metadata Integration]
158+
- [Time Series: Analyze Weather Data]
159159

160160
## Search
161161
CrateDB provides capabilities for full-text search, vector search, and hybrid
@@ -183,7 +183,7 @@ https://community.cratedb.com/t/resampling-time-series-data-with-date-bin/1009
183183
(window-functions)=
184184
## Window Functions
185185
- [Window functions in CrateDB]
186-
- [Time Series: Analyzing Weather Data]
186+
- [Time Series: Analyze Weather Data]
187187

188188

189189

@@ -228,7 +228,7 @@ It is also not in the same shape as the other pages in this section.
228228
:::
229229

230230

231-
[Analyzing Device Readings with Metadata Integration]: project:#timeseries-with-metadata
231+
[Analyze Device Readings with Metadata Integration]: project:#timeseries-with-metadata
232232
[bulk operations interface]: inv:crate-reference#http-bulk-ops
233233
[bulk operations for INSERTs]: project:#inserts_bulk_operations
234234
[HyperLogLog]: https://en.wikipedia.org/wiki/HyperLogLog
@@ -238,6 +238,6 @@ It is also not in the same shape as the other pages in this section.
238238
[Ingesting into CrateDB with UNNEST and Node.js]: https://community.cratedb.com/t/connecting-to-cratedb-with-node-js/751#ingesting-into-cratedb-with-unnest-3
239239
[Introducing: HyperLogLog]: https://cratedb.com/blog/feature-focus-making-things-hyper-fast-fast
240240
[Optimizing storage for historic time-series data]: https://community.cratedb.com/t/optimizing-storage-for-historic-time-series-data/762
241-
[Time Series: Analyzing Weather Data]: project:#timeseries-analysis-weather
241+
[Time Series: Analyze Weather Data]: project:#timeseries-analysis-weather
242242
[UNNEST]: project:#inserts_unnest
243243
[Window functions in CrateDB]: https://community.cratedb.com/t/window-functions-in-cratedb/1398

docs/integrate/trino/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
:::{rubric} About
1212
:::
1313

14-
[Trino] is a fast distributed SQL query engine for big data analytics
15-
that helps you explore your data universe.
14+
[Trino] is a fast, distributed SQL query engine for analytics.
1615

1716
:::{rubric} Learn
1817
:::

docs/integrate/trino/tutorial.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,47 @@
11
(trino-tutorial)=
22
# Connecting to CrateDB in Trino
33

4-
[Trino](https://trino.io/) (formerly known as Presto SQL) is a distributed query engine, that allows running analytical queries across different data sources via SQL. One of those data sources can be CrateDB and this article is going to look at how to configure the connection.
4+
[Trino](https://trino.io/) is a distributed SQL query engine. This tutorial shows how to configure Trino to connect to CrateDB.
55

66
## Prerequisites
77

8-
We assume a Trino client/server installation is already in place as per [Trino’s installation instructions](https://trino.io/docs/current/installation.html).
8+
Assume you have a Trino client/server installation as per the [installation instructions](https://trino.io/docs/current/installation.html).
99

10-
For this post, I installed Trino on macOS using Homebrew with `brew install trino` and my installation directory is `/usr/local/Cellar/trino/375`. Depending on your installation method, there might be different ways to start the Trino server. For the sake of this post, I start it in my console from the installation directory with the command `./bin/trino-server run`. Your preferred way of starting might differ.
10+
For example, on macOS you can `brew install trino`. Start the server with `trino-server run` from your installation’s `bin` directory. Depending on your installation, the command and paths may differ.
1111

1212
## Connector configuration
1313

14-
Due to CrateDB’s PostgreSQL protocol compatibility, we can make use of Trino’s [PostgreSQL connector](https://trino.io/docs/current/connector/postgresql.html). Create a new file `/usr/local/Cellar/trino/375/libexec/etc/catalog/postgresql.properties` to configure the connection:
14+
Because CrateDB speaks the PostgreSQL wire protocol, use Trino’s [PostgreSQL connector](https://trino.io/docs/current/connector/postgresql.html). Create a catalog properties file to configure the connection:
1515

16-
```
16+
```ini
1717
connector.name=postgresql
1818
connection-url=jdbc:postgresql://<CrateDB hostname>:5432/
1919
connection-user=<CrateDB username>
2020
connection-password=<CrateDB password>
2121
insert.non-transactional-insert.enabled=true
2222
```
2323

24-
Please replace the placeholders for the CrateDB hostname, username, and password to match your setup. Besides the connection details, the configuration has two particularities:
24+
Replace the placeholders for the CrateDB hostname, username, and password. Besides the connection details, note two specifics:
2525

26-
* No database name: With PostgreSQL, a JDBC connection URL usually ends with a database name. We intentionally omit the database name when connecting to CrateDB for compatibility reasons.
27-
CrateDB consists of a single database with multiple schemas, hence we do not specify a database name in the `connection-url`. If a database name is specified, you will run into an error message on certain operations (`ERROR: Table with more than 2 QualifiedName parts is not supported. Only <schema>.<tableName> works`).
28-
* Disabling transactions: Being a database with eventual consistency, CrateDB doesn’t support transactions. By default, the PostgreSQL connector will wrap `INSERT` queries into transactions and attempt to create a temporary table. We disable this behavior with the `insert.non-transactional-insert.enabled` parameter.
26+
* No database name: CrateDB provides a single database with multiple schemas, so omit the database name in `connection-url`. Specifying a database triggers errors for operations that include `catalog.schema.table` (e.g., `ERROR: Table with more than 2 QualifiedName parts is not supported. Only <schema>.<tableName> works`).
27+
* Non‑transactional inserts: CrateDB doesn’t support transactions. By default, the PostgreSQL connector wraps `INSERT` statements in a transaction and uses a temporary table. Disable this with `insert.non-transactional-insert.enabled=true`.
2928

3029
## Running queries against CrateDB
3130

32-
Once the PostgreSQL connector is configured, we can connect to the Trino server using its CLI:
31+
After configuring the connector, connect to the Trino server using its CLI:
3332

3433
```bash
3534
# schema refers to an existing CrateDB schema
3635
$ ./bin/trino --catalog postgresql --schema doc
3736
trino:doc>
3837
```
3938

40-
A `SHOW TABLES` query should successfully list all existing tables in the specified CrateDB schema and you can proceed with querying them.
39+
Run `SHOW TABLES` to list all tables in the specified CrateDB schema, then query them.
40+
41+
Because CrateDB speaks the PostgreSQL wire protocol, use Trino’s [PostgreSQL connector](https://trino.io/docs/current/connector/postgresql.html). Create a catalog file, for example:
4142

42-
As CrateDB differs in some aspects from PostgreSQL, there are a few particularities to consider for your queries:
43+
- macOS (Homebrew): `/usr/local/etc/trino/catalog/postgresql.properties` (or `/opt/homebrew/etc/trino/catalog/...` on Apple Silicon)
44+
- Linux (tarball/systemd): `$TRINO_HOME/etc/catalog/postgresql.properties` or `/etc/trino/catalog/postgresql.properties`
4345

4446
* Querying `OBJECT` columns: Columns of the data type `OBJECT` can usually be queried using the bracket notation, e.g. `SELECT my_object_column['my_object_key'] FROM my_table`. In Trino’s SQL dialect, the identifier needs to be wrapped in double quotes, such as `SELECT "my_object_column['my_object_key']" FROM my_table`.
4547
* `INSERT` queries: When inserting, Trino addresses tables with `catalog_name.schema_name.table_name`, which currently isn't supported by CrateDB. Please see [crate/crate#12658](https://github.com/crate/crate/issues/12658) on addressing this issue.
@@ -51,4 +53,6 @@ As CrateDB differs in some aspects from PostgreSQL, there are a few particularit
5153

5254
## Conclusion
5355

54-
With a few parameter tweaks, Trino can successfully connect to CrateDB. The information presented in this post is the result of a short compatibility test and is likely not exhaustive. If you use Trino with CrateDB and are aware of any additional aspects, please let us know!
56+
With a few parameter tweaks, Trino connects to CrateDB. This guide reflects a
57+
short compatibility test and is not exhaustive. If you discover additional
58+
aspects, please let us know.

0 commit comments

Comments
 (0)