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 +4 -4
- data/ChangeLog.md +3 -0
- data/README.md +13 -0
- data/lib/trino/client/query.rb +6 -3
- data/lib/trino/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9ecbdf7d017c29ac4e645d54564a701538724367f8ae62551c5e5dce705f91f
|
4
|
+
data.tar.gz: 78f07db77b0c6231c563c4a39a74e07d186c93b0b0ad03327439c9781e5d577d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/trino/client/query.rb
CHANGED
@@ -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 ||=
|
105
|
-
|
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(
|
113
|
+
rows.map { |row| transform_row(row) }
|
111
114
|
end
|
112
115
|
|
113
116
|
def transform_row(row)
|
data/lib/trino/client/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2023-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|