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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9450ad107fdacbc74c5bb6701fe14dffeedeea73271c482f9215c34560feea9
4
- data.tar.gz: edf1b44fcf2e83f231e7e98f9162e87518397f0b31dd5d6cf8ddc2dc517d62cf
3
+ metadata.gz: 72dd2cba77859f25d7d3ac35b9f76243036cfa627a375d76a7b50c0f0a146aee
4
+ data.tar.gz: 61782cf0551ef563b4f71f4a77cfaf2881757a8d51ebd1da2c5f1ecc53839a91
5
5
  SHA512:
6
- metadata.gz: c8b3d5ad1609dc68e8a5b5149d3381ffb103b0ef9aa6ac286eae9b0ff639b371ffa10ecd2734709e8710dcf43d62344548556f36d66d37bc2247b9d3e9339f70
7
- data.tar.gz: 64ab5b8eb78343a27d94097ff4a841b6855b8bb7a90ef6e79aecc87e2438c54e5998df5660ac45c0b65ffd426f21116376c6a4f91f3f0d927bd60a464c061384
6
+ metadata.gz: 5203bb457596d0c13e03df2164c0225164e3abf571ef55c6b4a3b3f472adf7a769cbeb496ef3387bb09ed90a1bf3c1521cc7c54a1a14d88ffd20a7b3fc00c089
7
+ data.tar.gz: 672c494c5e5af52289d23fd18521128735b4f9c4575a40389b401e84bf37a79edf0e6859e86028fde8cea489c68afd7ca259d381aa0237faa09142a3970b919d
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
 
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(server: 'localhost:8080', catalog: 'memory', user: 'tiny-user', schema: 'default')
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
- if RETRYABLE_ERRORS.any? { |err| e.message =~ err }
90
- sleep(1)
91
- next
92
- end
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
 
@@ -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
@@ -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' => [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TinyPresto
4
- VERSION = '0.0.6'.freeze
4
+ VERSION = '0.0.7'.freeze
5
5
  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 = 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 '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/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.6')
8
+ expect(TinyPresto::VERSION).to eq('0.0.5')
9
9
  end
10
10
  end
11
11
  end
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.6
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: 2020-02-17 00:00:00.000000000 Z
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.0.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: