pinot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +42 -0
- data/lib/pinot/client.rb +81 -0
- data/lib/pinot/response.rb +32 -0
- data/lib/pinot/version.rb +1 -1
- data/lib/pinot.rb +4 -0
- metadata +63 -5
- data/pinot.gemspec +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fa42f97735f850dc0f870866e7d6da882227a998533b3aaa94f7c6a320d20ec
|
4
|
+
data.tar.gz: '019daf46b029bdac3a7c196d0a5f2927234f63ba513873318c5e0f6d48e1d3c6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03e285bd5884bae307bd58797738d478f96cf97466ec0e6992dba0de6ab5120f935fba9245c4c5f1466794cf83da4a42dcc30b6819289e736c40cc374a054639
|
7
|
+
data.tar.gz: 07345f9e2e93442855887c208d586d98a0922bc346e19cac7bc58efbea1b4a79aadafaf9abd70692957890211583b2202502fe92996278f7e87f28a503fcfd88
|
data/Guardfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :minitest do
|
19
|
+
# with Minitest::Unit
|
20
|
+
watch(%r{^test/(.*)/?test_(.*)\.rb$})
|
21
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
22
|
+
watch(%r{^test/test_helper\.rb$}) { "test" }
|
23
|
+
|
24
|
+
# with Minitest::Spec
|
25
|
+
# watch(%r{^spec/(.*)_spec\.rb$})
|
26
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
27
|
+
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
28
|
+
|
29
|
+
# Rails 4
|
30
|
+
# watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
31
|
+
# watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
|
32
|
+
# watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
33
|
+
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
34
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
35
|
+
# watch(%r{^test/.+_test\.rb$})
|
36
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
37
|
+
|
38
|
+
# Rails < 4
|
39
|
+
# watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
40
|
+
# watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
|
41
|
+
# watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
42
|
+
end
|
data/lib/pinot/client.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
module Pinot
|
2
|
+
class Client
|
3
|
+
attr_reader :host, :port, :controller_host, :controller_port, :protocol
|
4
|
+
|
5
|
+
def initialize(host:, port:, controller_port:, controller_host: nil, protocol: :http)
|
6
|
+
@host = host
|
7
|
+
@port = port
|
8
|
+
@controller_port = controller_port
|
9
|
+
@controller_host = controller_host || host
|
10
|
+
@protocol = protocol
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(sql)
|
14
|
+
Response.new(JSON.parse(http.post(query_sql_uri, json: {sql: sql})))
|
15
|
+
end
|
16
|
+
|
17
|
+
def schema(name)
|
18
|
+
url = "#{controller_uri}/schemas/#{name}"
|
19
|
+
response = http.get(url)
|
20
|
+
JSON.parse(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete_segments(name, type: :offline)
|
24
|
+
type = type.to_s.upcase
|
25
|
+
url = "#{controller_uri}/segments/#{name}?type=#{type}"
|
26
|
+
response = http.delete(url)
|
27
|
+
JSON.parse(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_table(schema)
|
31
|
+
url = "#{controller_uri}/tables"
|
32
|
+
response = http.post(url, body: schema)
|
33
|
+
JSON.parse(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_table(name, type: :offline)
|
37
|
+
type = type.to_s.downcase
|
38
|
+
url = "#{controller_uri}/tables/#{name}?type=#{type}"
|
39
|
+
response = http.delete(url)
|
40
|
+
JSON.parse(response)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ingest_json(file, table:)
|
44
|
+
url = "#{controller_uri}/ingestFromFile?tableNameWithType=#{table}&batchConfigMapStr=%7B%22inputFormat%22%3A%22json%22%7D"
|
45
|
+
content_type = "multipart/form-data"
|
46
|
+
response = HTTPX.post(
|
47
|
+
url,
|
48
|
+
form: {
|
49
|
+
file: {
|
50
|
+
filename: File.basename(file.path),
|
51
|
+
content_type: content_type,
|
52
|
+
body: file.read
|
53
|
+
}
|
54
|
+
}
|
55
|
+
)
|
56
|
+
JSON.parse(response)
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_schema(schema, override: true, force: false)
|
60
|
+
url = "#{controller_uri}/schemas?override=#{override}&force=#{force}"
|
61
|
+
response = http.post(url, body: schema)
|
62
|
+
JSON.parse(response)
|
63
|
+
end
|
64
|
+
|
65
|
+
def http(content_type: "application/json")
|
66
|
+
HTTPX.with(headers: {"Content-Type" => content_type})
|
67
|
+
end
|
68
|
+
|
69
|
+
def uri
|
70
|
+
"#{protocol}://#{host}:#{port}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def controller_uri
|
74
|
+
"#{protocol}://#{controller_host}:#{controller_port}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def query_sql_uri
|
78
|
+
"#{uri}/query/sql"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Pinot
|
2
|
+
class Response
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(payload)
|
6
|
+
@payload = payload
|
7
|
+
end
|
8
|
+
|
9
|
+
def rows
|
10
|
+
@payload.dig("resultTable", "rows")
|
11
|
+
end
|
12
|
+
|
13
|
+
def columns
|
14
|
+
names = @payload.dig("resultTable", "dataSchema", "columnNames")
|
15
|
+
types = @payload.dig("resultTable", "dataSchema", "columnDataTypes")
|
16
|
+
return {} if @payload["exceptions"].any?
|
17
|
+
ix = 0
|
18
|
+
names ||= []
|
19
|
+
names.map do |name|
|
20
|
+
ret = [name, types[ix]]
|
21
|
+
ix += 1
|
22
|
+
ret
|
23
|
+
end.to_h
|
24
|
+
end
|
25
|
+
|
26
|
+
def each(&block)
|
27
|
+
rows.each do |row|
|
28
|
+
block.call(row)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pinot/version.rb
CHANGED
data/lib/pinot.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Celso Fernandes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httpx
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: guard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard-minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
13
69
|
description: Client for Apache Pinot
|
14
70
|
email:
|
15
71
|
- celso.fernandes@clickfunnels.com
|
@@ -20,11 +76,13 @@ files:
|
|
20
76
|
- ".standard.yml"
|
21
77
|
- CHANGELOG.md
|
22
78
|
- CODE_OF_CONDUCT.md
|
79
|
+
- Guardfile
|
23
80
|
- README.md
|
24
81
|
- Rakefile
|
25
82
|
- lib/pinot.rb
|
83
|
+
- lib/pinot/client.rb
|
84
|
+
- lib/pinot/response.rb
|
26
85
|
- lib/pinot/version.rb
|
27
|
-
- pinot.gemspec
|
28
86
|
- sig/pinot.rbs
|
29
87
|
homepage: https://github.com/fernandes/pinot-ruby
|
30
88
|
licenses: []
|
@@ -47,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
105
|
- !ruby/object:Gem::Version
|
48
106
|
version: '0'
|
49
107
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.5.3
|
51
109
|
signing_key:
|
52
110
|
specification_version: 4
|
53
111
|
summary: Client for Apache Pinot
|
data/pinot.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/pinot/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "pinot"
|
7
|
-
spec.version = Pinot::VERSION
|
8
|
-
spec.authors = ["Celso Fernandes"]
|
9
|
-
spec.email = ["celso.fernandes@clickfunnels.com"]
|
10
|
-
|
11
|
-
spec.summary = "Client for Apache Pinot"
|
12
|
-
spec.description = "Client for Apache Pinot"
|
13
|
-
spec.homepage = "https://github.com/fernandes/pinot-ruby"
|
14
|
-
spec.required_ruby_version = ">= 2.6.0"
|
15
|
-
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = "https://github.com/fernandes/pinot"
|
18
|
-
spec.metadata["changelog_uri"] = "https://github.com/fernandes/pinot/blob/main/CHANGELOG.md"
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(__dir__) do
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
(File.expand_path(f) == __FILE__) ||
|
25
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
spec.bindir = "exe"
|
29
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = ["lib"]
|
31
|
-
|
32
|
-
# Uncomment to register a new dependency of your gem
|
33
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
34
|
-
|
35
|
-
# For more information and examples about making a new gem, check out our
|
36
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
-
end
|