Skip to content

Business intelligence made simple

Added support for trino-client gem [skip ci]

Andrew Kanea5d21b7f9499
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f0c4bdb..50193200 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 3.2.0 (unreleased)
+- Added support for `trino-client` gem
- Added support for `neo4j-ruby-driver` gem
- Fixes types for SQLite
- Fixed table preview and schema page for SQLite
diff --git a/Gemfile b/Gemfile
index 3c8d0187..9c4b7a2a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,6 +31,7 @@ gem "propshaft"
# gem "restforce"
# gem "tiny_tds"
# gem "trilogy"
+# gem "trino-client"
# gem "activerecord-sqlserver-adapter"
# anomaly detection and forecasting
diff --git a/README.md b/README.md
index 3d2d4a90..6962a274 100644
--- a/README.md
+++ b/README.md
@@ -585,7 +585,7 @@ data_sources:
- [OpenSearch](#opensearch)
- [Oracle](#oracle)
- [PostgreSQL](#postgresql-1)
-- [Presto](#presto)
+- [Presto and Trino](#presto-and-trino)
- [Salesforce](#salesforce)
- [Snowflake](#snowflake)
- [Socrata Open Data API (SODA)](#socrata-open-data-api-soda)
@@ -855,17 +855,19 @@ data_sources:
Use a [read-only user](#postgresql).
-### Presto
+### Presto and Trino
-Add [presto-client](https://github.com/treasure-data/presto-client-ruby) to your Gemfile and set:
+Add [presto-client](https://github.com/treasure-data/trino-client-ruby/tree/v0.6.5) or [trino-client](https://github.com/treasure-data/trino-client-ruby) to your Gemfile and set:
```yml
data_sources:
my_source:
url: presto://user@hostname:8080/catalog
+ # or
+ url: trino://user@hostname:8080/catalog
```
-Use a [read-only user](https://prestodb.io/docs/current/security/built-in-system-access-control.html).
+Use a read-only user for [Presto](https://prestodb.io/docs/current/security/built-in-system-access-control.html) or [Trino](https://trino.io/docs/current/security/built-in-system-access-control.html).
### Salesforce
diff --git a/lib/blazer/adapters.rb b/lib/blazer/adapters.rb
index eed81a49..338d4bcc 100644
--- a/lib/blazer/adapters.rb
+++ b/lib/blazer/adapters.rb
@@ -15,3 +15,4 @@ Blazer.register_adapter "soda", Blazer::Adapters::SodaAdapter
Blazer.register_adapter "spark", Blazer::Adapters::SparkAdapter
Blazer.register_adapter "sql", Blazer::Adapters::SqlAdapter
Blazer.register_adapter "snowflake", Blazer::Adapters::SnowflakeAdapter
+Blazer.register_adapter "trino", Blazer::Adapters::PrestoAdapter
diff --git a/lib/blazer/adapters/presto_adapter.rb b/lib/blazer/adapters/presto_adapter.rb
index d94824f0..8d0a625d 100644
--- a/lib/blazer/adapters/presto_adapter.rb
+++ b/lib/blazer/adapters/presto_adapter.rb
@@ -40,7 +40,8 @@ module Blazer
@client ||= begin
uri = URI.parse(settings["url"])
query = uri.query ? CGI.parse(uri.query) : {}
- Presto::Client.new(
+ cls = uri.scheme == "trino" ? Trino::Client : Presto::Client
+ cls.new(
server: "#{uri.host}:#{uri.port}",
catalog: uri.path.to_s.delete_prefix("/"),
schema: query["schema"] || "public",
diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rb
index 19b45f75..51b78c4a 100644
--- a/lib/blazer/data_source.rb
+++ b/lib/blazer/data_source.rb
@@ -256,7 +256,7 @@ module Blazer
def detect_adapter
scheme = settings["url"].to_s.split("://").first
case scheme
- when "presto", "cassandra", "ignite"
+ when "presto", "trino", "cassandra", "ignite"
scheme
else
"sql"
diff --git a/test/support/adapters.yml b/test/support/adapters.yml
index d42b214d..7e258320 100644
--- a/test/support/adapters.yml
+++ b/test/support/adapters.yml
@@ -50,7 +50,7 @@ data_sources:
url: postgres://localhost/blazer_test
presto:
- url: presto://user@localhost:8080/jmx
+ url: trino://user@localhost:8080/jmx
redshift:
url: redshift://localhost:5439/blazer_test