trino-client 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 887c8e77f79998cb038d93f27879b2ca268d455343cb4628b865306ba894ab1d
4
- data.tar.gz: 2f28c84bc26e36da9de4f5b3d275d099ecd304341f6640bd75c973fd8d14eded
3
+ metadata.gz: a9ecbdf7d017c29ac4e645d54564a701538724367f8ae62551c5e5dce705f91f
4
+ data.tar.gz: 78f07db77b0c6231c563c4a39a74e07d186c93b0b0ad03327439c9781e5d577d
5
5
  SHA512:
6
- metadata.gz: 34c0baa8b9f349abc713cb1ddfcd639d04a755308c8836a504fe6e58b62992f5cea14c34e8df3d29ae0351770550519aaf3d70f12ba8a63b5a8d28ffec463dc4
7
- data.tar.gz: fd12c7387e02b80911b2a1f6f95e68fa2e4ce798b3dea762c9097d9809847993840d424a4b47a95e62bf1ff6649294649ec184065beb83b86f12b5ba2a655900
6
+ metadata.gz: 2c6c3b16e146d2141df38a4bd10e873cedcb18d3a0f6cb8908122382ac2cc44b471a27a4c243981ff9783da450f497ef4219d6bf4a4cc1c4e94a7d2a6ab084f2
7
+ data.tar.gz: 71bf6ac5e65dada7e5f02f03f7abf13132a81849520720a41641acc2041ef2bfbd4f8000de476d968dfec3c5666cf94c6acff52ec2771aaabb924bfddd228d44
data/ChangeLog.md CHANGED
@@ -1,5 +1,8 @@
1
1
  trino-client-ruby
2
2
  ====
3
+ ## 2.2.0
4
+ - Add transform_row and scalar_parser documentation and make them easier to use ([#118](https://github.com/treasure-data/trino-client-ruby/issues/118)) [[41ffca7](https://github.com/treasure-data/trino-client-ruby/commit/41ffca7)]
5
+
3
6
  ## 2.1.0
4
7
  - Add utility for transforming Trino ROW type columns into Ruby hashes ([#117](https://github.com/treasure-data/trino-client-ruby/issues/117)) [[e14251c](https://github.com/treasure-data/trino-client-ruby/commit/e14251c)]
5
8
  - Bump actions/checkout from 3 to 4 ([#116](https://github.com/treasure-data/trino-client-ruby/issues/116)) [[ebd9d9e](https://github.com/treasure-data/trino-client-ruby/commit/ebd9d9e)]
data/README.md CHANGED
@@ -64,6 +64,19 @@ query = client.query("select * from sys.node")
64
64
  query_id = query.query_info.query_id
65
65
  query.each_row {|row| ... } # when a thread is processing the query,
66
66
  client.kill(query_id) # another thread / process can kill the query.
67
+
68
+ # Use Query#transform_row to parse Trino ROW types into Ruby Hashes.
69
+ # You can also set a scalar_parser to parse scalars how you'd like them.
70
+ scalar_parser = -> (data, type) { (type === 'json') ? JSON.parse(data) : data }
71
+ client.query("select * from sys.node") do |q|
72
+ q.scalar_parser = scalar_parser
73
+
74
+ # get query results. it feeds more rows until
75
+ # query execution finishes:
76
+ q.each_row {|row|
77
+ p q.transform_row(row)
78
+ }
79
+ end
67
80
  ```
68
81
 
69
82
  ## Build models
@@ -58,6 +58,8 @@ module Trino::Client
58
58
  row_object
59
59
  end
60
60
 
61
+ attr_accessor :scalar_parser
62
+
61
63
  def initialize(api)
62
64
  @api = api
63
65
  end
@@ -101,13 +103,14 @@ module Trino::Client
101
103
  end
102
104
 
103
105
  def column_value_parsers
104
- @column_value_parsers ||= columns.map {|column|
105
- ColumnValueParser.new(column)
106
+ @column_value_parsers ||= {}
107
+ @column_value_parsers[scalar_parser] ||= columns.map {|column|
108
+ ColumnValueParser.new(column, scalar_parser)
106
109
  }
107
110
  end
108
111
 
109
112
  def transform_rows
110
- rows.map(&:transform_row)
113
+ rows.map { |row| transform_row(row) }
111
114
  end
112
115
 
113
116
  def transform_row(row)
@@ -15,6 +15,6 @@
15
15
  #
16
16
  module Trino
17
17
  module Client
18
- VERSION = "2.1.0"
18
+ VERSION = "2.2.0"
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trino-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-19 00:00:00.000000000 Z
11
+ date: 2023-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday