{"id":27627190,"url":"https://github.com/treasure-data/trino-client-ruby","last_synced_at":"2025-04-23T13:53:27.606Z","repository":{"id":13014917,"uuid":"15694374","full_name":"treasure-data/trino-client-ruby","owner":"treasure-data","description":"Trino/Presto client library for Ruby","archived":false,"fork":false,"pushed_at":"2025-03-17T10:44:01.000Z","size":374,"stargazers_count":70,"open_issues_count":11,"forks_count":46,"subscribers_count":79,"default_branch":"master","last_synced_at":"2025-03-17T10:53:08.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treasure-data.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-07T03:47:29.000Z","updated_at":"2025-03-17T10:43:41.000Z","dependencies_parsed_at":"2023-02-19T14:46:02.784Z","dependency_job_id":"8fe9470e-8aeb-49e8-b8c8-92bac1a335e6","html_url":"https://github.com/treasure-data/trino-client-ruby","commit_stats":{"total_commits":225,"total_committers":27,"mean_commits":8.333333333333334,"dds":0.7911111111111111,"last_synced_commit":"2308c05f40d7317818d5fa072c33d70bd40e399d"},"previous_names":["treasure-data/presto-client-ruby"],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftrino-client-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftrino-client-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftrino-client-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treasure-data%2Ftrino-client-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treasure-data","download_url":"https://codeload.github.com/treasure-data/trino-client-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249885756,"owners_count":21340190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T13:53:26.798Z","updated_at":"2025-04-23T13:53:27.596Z","avatar_url":"https://github.com/treasure-data.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trino client library for Ruby\n\n[![Ruby](https://github.com/treasure-data/trino-client-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/treasure-data/trino-client-ruby/actions/workflows/ruby.yml) [![Gem](https://img.shields.io/gem/v/trino-client)](https://rubygems.org/gems/trino-client) [![Gem](https://img.shields.io/gem/dt/trino-client)](https://rubygems.org/gems/trino-client) [![GitHub](https://img.shields.io/github/license/treasure-data/trino-client-ruby)]()\n\nTrino is a distributed SQL query engine for big data:\nhttps://trino.io/\n\nThis is a client library for Ruby to run queries on Trino.\n\n## Example\n\n```ruby\nrequire 'trino-client'\n\n# create a client object:\nclient = Trino::Client.new(\n  server: \"localhost:8880\",   # required option\n  ssl: {verify: false},\n  catalog: \"native\",\n  schema: \"default\",\n  user: \"frsyuki\",\n  password: \"********\",\n  time_zone: \"US/Pacific\",\n  language: \"English\",\n  properties: {\n    \"hive.force_local_scheduling\": true,\n    \"raptor.reader_stream_buffer_size\": \"32MB\"\n  },\n  http_proxy: \"proxy.example.com:8080\",\n  http_debug: true\n)\n\n# run a query and get results as an array of arrays:\ncolumns, rows = client.run(\"select * from sys.node\")\nrows.each {|row|\n  p row  # row is an array\n}\n\n# run a query and get results as an array of hashes:\nresults = client.run_with_names(\"select alpha, 1 AS beta from tablename\")\nresults.each {|row|\n  p row['alpha']   # access by name\n  p row['beta']\n  p row.values[0]  # access by index\n  p row.values[1]\n}\n\n# run a query and fetch results streamingly:\nclient.query(\"select * from sys.node\") do |q|\n  # get columns:\n  q.columns.each {|column|\n    puts \"column: #{column.name}.#{column.type}\"\n  }\n\n  # get query results. it feeds more rows until\n  # query execution finishes:\n  q.each_row {|row|\n    p row  # row is an array\n  }\nend\n\n# killing a query\nquery = client.query(\"select * from sys.node\")\nquery_id = query.query_info.query_id\nquery.each_row {|row| ... }  # when a thread is processing the query,\nclient.kill(query_id)  # another thread / process can kill the query.\n\n# Use Query#transform_row to parse Trino ROW types into Ruby Hashes.\n# You can also set a scalar_parser to parse scalars how you'd like them.\nscalar_parser = -\u003e (data, type) { (type === 'json') ? JSON.parse(data) : data }\nclient.query(\"select * from sys.node\") do |q|\n  q.scalar_parser = scalar_parser\n\n  # get query results. it feeds more rows until\n  # query execution finishes:\n  q.each_row {|row|\n    p q.transform_row(row)\n  }\nend\n```\n\n## Build models\n\n```\n$ bundle exec rake modelgen:latest\n```\n\n## Options\n\n* **server** sets address (and port) of a Trino coordinator server.\n* **ssl** enables https.\n  * Setting `true` enables SSL and verifies server certificate using system's built-in certificates.\n  * Setting `{verify: false}` enables SSL but doesn't verify server certificate.\n  * Setting a Hash object enables SSL and verify server certificate with options:\n    * **ca_file**: path of a CA certification file in PEM format\n    * **ca_path**: path of a CA certification directory containing certifications in PEM format\n    * **cert_store**: a `OpenSSL::X509::Store` object used for verification\n    * **client_cert**: a `OpenSSL::X509::Certificate` object as client certificate\n    * **client_key**: a `OpenSSL::PKey::RSA` or `OpenSSL::PKey::DSA` object used for client certificate\n* **catalog** sets catalog (connector) name of Trino such as `hive-cdh4`, `hive-hadoop1`, etc.\n* **schema** sets default schema name of Trino. You need to use qualified name like `FROM myschema.table1` to use non-default schemas.\n* **source** sets source name to connect to a Trino. This name is shown on Trino web interface.\n* **client_info** sets client info to queries. It can be a string to pass a raw string, or an object that can be encoded to JSON.\n* **client_tags** sets client tags to queries. It needs to be an array of strings. The tags are shown on web interface.\n* **user** sets user name to connect to a Trino.\n* **password** sets a password to connect to Trino using basic auth.\n* **time_zone** sets time zone of queries. Time zone affects some functions such as `format_datetime`.\n* **language** sets language of queries. Language affects some functions such as `format_datetime`.\n* **properties** set session properties. Session properties affect internal behavior such as `hive.force_local_scheduling: true`, `raptor.reader_stream_buffer_size: \"32MB\"`, etc.\n* **query_timeout** sets timeout in seconds for the entire query execution (from the first API call until there're no more output data). If timeout happens, client raises TrinoQueryTimeoutError. Default is nil (disabled).\n* **plan_timeout** sets timeout in seconds for query planning execution (from the first API call until result columns become available). If timeout happens, client raises TrinoQueryTimeoutError. Default is nil (disabled).\n* **http_headers** sets custom HTTP headers. It must be a Hash of string to string.\n* **http_proxy** sets host:port of a HTTP proxy server.\n* **http_debug** enables debug message to STDOUT for each HTTP requests.\n* **http_open_timeout** sets timeout in seconds to open new HTTP connection.\n* **http_timeout** sets timeout in seconds to read data from a server.\n* **gzip** enables gzip compression.\n* **follow_redirect** enables HTTP redirection support.\n* **model_version** set the Trino version to which a job is submitted. Supported versions are 351, 316, 303, 0.205, 0.178, 0.173, 0.153 and 0.149. Default is 351.\n\nSee [RDoc](http://www.rubydoc.info/gems/presto-client/) for the full documentation.\n\n## Development\n\n### Releasing a new version\n\n1. First update `lib/trino/client/version.rb` to the next version.\n2. Run the following command which will update `ChangeLog.md` file automatically.\n```\n$ ruby release.rb\n```\n\n3. Create tag\n```\n$ git commit -am \"vX.Y.Z\"\n$ git tag \"vX.Y.Z\"\n% git push --tags\n```\n\n4. Push package by the following command which will build and push `trino-client-X.Y.Z.gem` and `trino-client-ruby-X.Y.Z.gem` automatically.\n```\n$ ruby publish.rb\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreasure-data%2Ftrino-client-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreasure-data%2Ftrino-client-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreasure-data%2Ftrino-client-ruby/lists"}