tiny-presto 0.0.4 → 0.0.8
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/Gemfile +1 -1
- data/Gemfile.lock +10 -7
- data/README.md +3 -1
- data/lib/tiny-presto/cluster.rb +2 -2
- data/lib/tiny-presto/version.rb +1 -1
- data/lib/tiny-presto.rb +25 -19
- data/spec/cluster_spec.rb +13 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/version_spec.rb +1 -1
- data/tiny-presto.gemspec +2 -2
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dba27ee16b81873773d523431e07970d9f7b9aa4ec806309d0a72351761c4dc
|
4
|
+
data.tar.gz: bf1cc0cfaa83f1ece6923ee1d5564b333fd4a7b781e8b17509e136b0fe6d4486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dcadf67d4e8d0034e88d4c97f2c5c8958e19490323a5ad5de763b1ed496c7d98d4f493e94e3f060d69f00b8fa4fd25655c8e07f27b4f42fd5f546cfc607b651
|
7
|
+
data.tar.gz: a2ea14dd12b1d01c431aaf7ef4bad86caaee988ee3a6bd0f87848b4d15cbfee632466a9922f3d0a79e23e55638a60a0f86d5f8b27aa10d239db9b2f1bb37df8a
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,18 +7,17 @@ GEM
|
|
7
7
|
excon (>= 0.47.0)
|
8
8
|
multi_json
|
9
9
|
excon (0.71.1)
|
10
|
-
faraday (0.17.
|
10
|
+
faraday (0.17.4)
|
11
11
|
multipart-post (>= 1.2, < 3)
|
12
|
-
|
12
|
+
faraday_middleware (0.12.2)
|
13
|
+
faraday (>= 0.7.4, < 1.0)
|
14
|
+
msgpack (1.4.2)
|
13
15
|
multi_json (1.14.1)
|
14
16
|
multipart-post (2.1.1)
|
15
17
|
parallel (1.17.0)
|
16
18
|
parser (2.5.3.0)
|
17
19
|
ast (~> 2.4.0)
|
18
20
|
powerpack (0.1.2)
|
19
|
-
presto-client (0.6.1)
|
20
|
-
faraday (~> 0.12)
|
21
|
-
msgpack (>= 0.7.0)
|
22
21
|
rainbow (3.0.0)
|
23
22
|
rake (13.0.1)
|
24
23
|
rdoc (6.2.1)
|
@@ -43,6 +42,10 @@ GEM
|
|
43
42
|
ruby-progressbar (~> 1.7)
|
44
43
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
45
44
|
ruby-progressbar (1.10.0)
|
45
|
+
trino-client (1.0.0)
|
46
|
+
faraday (~> 0.12)
|
47
|
+
faraday_middleware (~> 0.12.2)
|
48
|
+
msgpack (>= 0.7.0)
|
46
49
|
unicode-display_width (1.4.0)
|
47
50
|
|
48
51
|
PLATFORMS
|
@@ -50,11 +53,11 @@ PLATFORMS
|
|
50
53
|
|
51
54
|
DEPENDENCIES
|
52
55
|
docker-api
|
53
|
-
presto-client
|
54
56
|
rake
|
55
57
|
rdoc
|
56
58
|
rspec
|
57
59
|
rubocop
|
60
|
+
trino-client
|
58
61
|
|
59
62
|
BUNDLED WITH
|
60
|
-
2.
|
63
|
+
2.2.22
|
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/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
|
data/lib/tiny-presto/version.rb
CHANGED
data/lib/tiny-presto.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tiny-presto/version'
|
|
4
4
|
require 'tiny-presto/cluster'
|
5
5
|
|
6
6
|
require 'singleton'
|
7
|
-
require '
|
7
|
+
require 'trino-client'
|
8
8
|
|
9
9
|
module TinyPresto
|
10
10
|
# Singleton object representing a Presto cluster running in the local machine.
|
@@ -16,7 +16,17 @@ module TinyPresto
|
|
16
16
|
def initialize
|
17
17
|
@cluster = Cluster.new
|
18
18
|
@cluster.run
|
19
|
-
@client =
|
19
|
+
@client = Trino::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
|
@@ -32,18 +42,15 @@ module TinyPresto
|
|
32
42
|
end
|
33
43
|
|
34
44
|
def self.print_record(record)
|
35
|
-
ret =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"'#{v}'"
|
43
|
-
end
|
45
|
+
ret = record.map do |v|
|
46
|
+
if v.is_a? Numeric
|
47
|
+
v.to_s
|
48
|
+
else
|
49
|
+
# Non numeric value is interpreted as string
|
50
|
+
"'#{v}'"
|
51
|
+
end
|
44
52
|
end
|
45
|
-
ret
|
46
|
-
ret
|
53
|
+
"(#{ret.join(',')})"
|
47
54
|
end
|
48
55
|
|
49
56
|
def self.prepare(table_name, table_data)
|
@@ -59,13 +66,11 @@ module TinyPresto
|
|
59
66
|
end
|
60
67
|
end
|
61
68
|
end
|
62
|
-
values_clause =
|
63
|
-
records.
|
64
|
-
values_clause << ',' if idx != 0
|
69
|
+
values_clause = []
|
70
|
+
records.each do |record|
|
65
71
|
values_clause << print_record(record)
|
66
72
|
end
|
67
|
-
|
68
|
-
query = "CREATE TABLE #{table_name} AS SELECT * FROM #{values_clause} t(#{columns.join(',')})"
|
73
|
+
query = "CREATE TABLE #{table_name} AS SELECT * FROM (values #{values_clause.join(',')}) t(#{columns.join(',')})"
|
69
74
|
run_with_retry(query)
|
70
75
|
end
|
71
76
|
|
@@ -86,10 +91,11 @@ module TinyPresto
|
|
86
91
|
def self.run_with_retry(sql, max_retry = 3)
|
87
92
|
max_retry.times do
|
88
93
|
return run(sql)
|
89
|
-
rescue
|
94
|
+
rescue Trino::Client::TrinoQueryError => e
|
90
95
|
# Cluster may be in the initialization phase.
|
91
96
|
raise unless e.message.match?(/^No nodes available to run query/)
|
92
97
|
|
98
|
+
sleep(1000)
|
93
99
|
next
|
94
100
|
end
|
95
101
|
end
|
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 =
|
10
|
+
@client = Trino::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/spec_helper.rb
CHANGED
data/spec/version_spec.rb
CHANGED
data/tiny-presto.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = 'Wrapper for Lightweight Presto Cluster'
|
12
12
|
gem.summary = 'For Presto functionality testing'
|
13
13
|
gem.homepage = 'https://github.com/Lewuathe/tiny-presto'
|
14
|
-
gem.license = 'Apache
|
14
|
+
gem.license = 'Apache-2.0'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.required_ruby_version = '>= 2.4.0'
|
23
23
|
|
24
24
|
gem.add_dependency 'docker-api', ['~> 1.34.0']
|
25
|
-
gem.add_dependency '
|
25
|
+
gem.add_dependency 'trino-client'
|
26
26
|
|
27
27
|
gem.add_development_dependency 'rake', ['~> 13.0.0']
|
28
28
|
gem.add_development_dependency 'rspec', ['~> 3.9.0']
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Sasaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.34.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: trino-client
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- tiny-presto.gemspec
|
94
94
|
homepage: https://github.com/Lewuathe/tiny-presto
|
95
95
|
licenses:
|
96
|
-
- Apache
|
96
|
+
- Apache-2.0
|
97
97
|
metadata: {}
|
98
98
|
post_install_message:
|
99
99
|
rdoc_options: []
|
@@ -110,7 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.7.6.2
|
114
115
|
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: For Presto functionality testing
|