tiny-presto 0.0.6 → 0.0.7
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/README.md +3 -1
- data/lib/tiny-presto.rb +15 -9
- data/lib/tiny-presto/cluster.rb +2 -3
- data/lib/tiny-presto/version.rb +1 -1
- data/spec/cluster_spec.rb +13 -4
- data/spec/version_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72dd2cba77859f25d7d3ac35b9f76243036cfa627a375d76a7b50c0f0a146aee
|
4
|
+
data.tar.gz: 61782cf0551ef563b4f71f4a77cfaf2881757a8d51ebd1da2c5f1ecc53839a91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5203bb457596d0c13e03df2164c0225164e3abf571ef55c6b4a3b3f472adf7a769cbeb496ef3387bb09ed90a1bf3c1521cc7c54a1a14d88ffd20a7b3fc00c089
|
7
|
+
data.tar.gz: 672c494c5e5af52289d23fd18521128735b4f9c4575a40389b401e84bf37a79edf0e6859e86028fde8cea489c68afd7ca259d381aa0237faa09142a3970b919d
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# tiny-presto [](https://github.com/Lewuathe/tiny-presto/actions)  
|
2
2
|
|
3
|
-
Tiny [
|
3
|
+
Tiny [Trino](https://trino.io/) cluster to check the compatibility of query result by using the specific Trino version.
|
4
|
+
|
5
|
+
**NOTE: The brand name of [Presto was migrated to Trino](https://trino.io/blog/2020/12/27/announcing-trino.html). Although the internal docker image used in tiny-presto was also migrated to [Trino](https://hub.docker.com/r/trinodb/trino), we keep the package name `tiny-presto` to avoid the installation trouble.**
|
4
6
|
|
5
7
|
# Install
|
6
8
|
|
data/lib/tiny-presto.rb
CHANGED
@@ -16,7 +16,17 @@ module TinyPresto
|
|
16
16
|
def initialize
|
17
17
|
@cluster = Cluster.new
|
18
18
|
@cluster.run
|
19
|
-
@client = Presto::Client.new(
|
19
|
+
@client = Presto::Client.new(
|
20
|
+
server: 'localhost:8080',
|
21
|
+
catalog: 'memory',
|
22
|
+
user: 'tiny-user',
|
23
|
+
schema: 'default',
|
24
|
+
# TODO: Remove after presto-client-ruby supports Trino
|
25
|
+
http_headers: {
|
26
|
+
'X-Trino-User' => 'tiny-user',
|
27
|
+
'X-Trino-Catalog' => 'memory',
|
28
|
+
'X-Trino-Schema' => 'default'
|
29
|
+
})
|
20
30
|
loop do
|
21
31
|
@client.run('show schemas')
|
22
32
|
break
|
@@ -74,9 +84,6 @@ module TinyPresto
|
|
74
84
|
rows
|
75
85
|
end
|
76
86
|
|
77
|
-
RETRYABLE_ERRORS = [
|
78
|
-
/No nodes available to run query/
|
79
|
-
]
|
80
87
|
# Run the given query with retrying in case of undeterministic error.
|
81
88
|
#
|
82
89
|
# TinyPresto.run_with_retry("show schemas")
|
@@ -86,11 +93,10 @@ module TinyPresto
|
|
86
93
|
return run(sql)
|
87
94
|
rescue Presto::Client::PrestoQueryError => e
|
88
95
|
# Cluster may be in the initialization phase.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
raise
|
96
|
+
raise unless e.message.match?(/^No nodes available to run query/)
|
97
|
+
|
98
|
+
sleep(1000)
|
99
|
+
next
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
data/lib/tiny-presto/cluster.rb
CHANGED
@@ -6,9 +6,9 @@ module TinyPresto
|
|
6
6
|
# Represents a Presto cluster
|
7
7
|
#
|
8
8
|
class Cluster
|
9
|
-
def initialize(tag = 'latest')
|
9
|
+
def initialize(image = 'trinodb/trino', tag = 'latest')
|
10
10
|
@tag = tag
|
11
|
-
@image_name = "
|
11
|
+
@image_name = "#{image}:#{@tag}"
|
12
12
|
end
|
13
13
|
|
14
14
|
# Launch Presto cluster running on Docker container
|
@@ -17,7 +17,6 @@ module TinyPresto
|
|
17
17
|
Docker::Image.create('fromImage' => @image_name)
|
18
18
|
@container = Docker::Container.create(
|
19
19
|
'Image' => @image_name,
|
20
|
-
'ExposedPorts' => { '8080/tcp' => {} },
|
21
20
|
'HostConfig' => {
|
22
21
|
'PortBindings' => {
|
23
22
|
'8080/tcp' => [
|
data/lib/tiny-presto/version.rb
CHANGED
data/spec/cluster_spec.rb
CHANGED
@@ -7,12 +7,21 @@ RSpec.describe TinyPresto::Cluster do
|
|
7
7
|
before(:all) do
|
8
8
|
@cluster = TinyPresto::Cluster.new
|
9
9
|
@container = @cluster.run
|
10
|
-
@client = Presto::Client.new(
|
10
|
+
@client = Presto::Client.new(
|
11
|
+
server: 'localhost:8080',
|
12
|
+
catalog: 'memory',
|
13
|
+
user: 'tiny-user',
|
14
|
+
schema: 'default',
|
15
|
+
# TODO: Remove after presto-client-ruby supports Trino
|
16
|
+
http_headers: {
|
17
|
+
'X-Trino-User' => 'tiny-user',
|
18
|
+
'X-Trino-Catalog' => 'memory'
|
19
|
+
})
|
11
20
|
loop do
|
12
21
|
@client.run('show schemas')
|
13
22
|
break
|
14
23
|
rescue StandardError => exception
|
15
|
-
puts
|
24
|
+
puts "Waiting for cluster ready... #{exception}"
|
16
25
|
sleep(3)
|
17
26
|
end
|
18
27
|
puts 'Cluster is ready'
|
@@ -32,8 +41,8 @@ RSpec.describe TinyPresto::Cluster do
|
|
32
41
|
end
|
33
42
|
|
34
43
|
it 'run CTAS query' do
|
35
|
-
@client.run("create table ctas1 as select * from (values (1, 'a'), (2, 'b')) t(c1, c2)")
|
36
|
-
columns, rows = @client.run('select * from ctas1')
|
44
|
+
@client.run("create table default.ctas1 as select * from (values (1, 'a'), (2, 'b')) t(c1, c2)")
|
45
|
+
columns, rows = @client.run('select * from default.ctas1')
|
37
46
|
expect(columns.map(&:name)).to match_array(%w[c1 c2])
|
38
47
|
end
|
39
48
|
end
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny-presto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Sasaki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -95,7 +95,7 @@ homepage: https://github.com/Lewuathe/tiny-presto
|
|
95
95
|
licenses:
|
96
96
|
- Apache-2.0
|
97
97
|
metadata: {}
|
98
|
-
post_install_message:
|
98
|
+
post_install_message:
|
99
99
|
rdoc_options: []
|
100
100
|
require_paths:
|
101
101
|
- lib
|
@@ -110,8 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
114
|
-
signing_key:
|
113
|
+
rubygems_version: 3.1.4
|
114
|
+
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: For Presto functionality testing
|
117
117
|
test_files:
|