tiny-presto 0.0.4 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22d98c71de7a327595dd05b6a59a8ed1ff747208995eb9ab5c02bc4ef954dade
4
- data.tar.gz: 86b59421bc8379e130956108781965da6d51bad55bb274b907ba53ae688c0d4a
3
+ metadata.gz: 6dba27ee16b81873773d523431e07970d9f7b9aa4ec806309d0a72351761c4dc
4
+ data.tar.gz: bf1cc0cfaa83f1ece6923ee1d5564b333fd4a7b781e8b17509e136b0fe6d4486
5
5
  SHA512:
6
- metadata.gz: 47f6d98e15f9071f31c424fcb63f8521f7b99a09c796bbac4df5447da5ba494101460f56d6a242b213737b9ba57af3fdc2bc2498cb390a961bdc5a2366fe467d
7
- data.tar.gz: a1801999ed1897d976e70d90b8728f92b428a91b08a8fd29a703d852728b2f1e4cc895b0ecaeac7dd09f650bc6ebb24f505f3de362e6f942fa48f10e96411920
6
+ metadata.gz: 7dcadf67d4e8d0034e88d4c97f2c5c8958e19490323a5ad5de763b1ed496c7d98d4f493e94e3f060d69f00b8fa4fd25655c8e07f27b4f42fd5f546cfc607b651
7
+ data.tar.gz: a2ea14dd12b1d01c431aaf7ef4bad86caaee988ee3a6bd0f87848b4d15cbfee632466a9922f3d0a79e23e55638a60a0f86d5f8b27aa10d239db9b2f1bb37df8a
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  gem 'docker-api'
8
- gem 'presto-client'
8
+ gem 'trino-client'
9
9
  gem 'rake'
10
10
  gem 'rdoc'
11
11
  gem 'rubocop'
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.3)
10
+ faraday (0.17.4)
11
11
  multipart-post (>= 1.2, < 3)
12
- msgpack (1.3.1)
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.0.2
63
+ 2.2.22
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # tiny-presto [![Actions Status](https://github.com/Lewuathe/tiny-presto/workflows/test/badge.svg)](https://github.com/Lewuathe/tiny-presto/actions) ![Gem](https://img.shields.io/gem/v/tiny-presto) ![Gem](https://img.shields.io/gem/dt/tiny-presto)
2
2
 
3
- Tiny [Presto](https://prestosql.io/) cluster to check the compatibility of query result by using the specific Presto version.
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
 
@@ -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 = "prestosql/presto:#{@tag}"
11
+ @image_name = "#{image}:#{@tag}"
12
12
  end
13
13
 
14
14
  # Launch Presto cluster running on Docker container
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TinyPresto
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.8'.freeze
5
5
  end
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 'presto-client'
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 = Presto::Client.new(server: 'localhost:8080', catalog: 'memory', user: 'tiny-user', schema: 'default')
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
- record.each_with_index do |v, idx|
37
- ret << ',' if idx != 0
38
- ret << if v.is_a? Numeric
39
- v.to_s
40
- else
41
- # Non numeric value is interpreted as string
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 = '(values '
63
- records.each_with_index do |record, idx|
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
- values_clause << ')'
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 Presto::Client::PrestoQueryError => e
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 = Presto::Client.new(server: 'localhost:8080', catalog: 'memory', user: 'tiny-user', schema: 'default')
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 'Waiting for cluster ready...'
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
@@ -11,4 +11,4 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
 
13
13
  require 'tiny-presto'
14
- require 'presto-client'
14
+ require 'trino-client'
data/spec/version_spec.rb CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  RSpec.describe TinyPresto do
6
6
  describe '#version' do
7
7
  it 'correct' do
8
- expect(TinyPresto::VERSION).to eq('0.0.3')
8
+ expect(TinyPresto::VERSION).to eq('0.0.8')
9
9
  end
10
10
  end
11
11
  end
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 2.0'
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 'faraday', ['~> 0.12']
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
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: 2020-02-12 00:00:00.000000000 Z
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: faraday
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.12'
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.12'
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 2.0
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
- rubygems_version: 3.0.3
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