impala 0.5.0 → 0.5.1
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/lib/impala/connection.rb +5 -15
- data/lib/impala/version.rb +1 -1
- data/test/test_impala.rb +4 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d04d8e537a01c0ba40812df78ee3746c11ef63
|
4
|
+
data.tar.gz: 3de3a3dea1535e62fa72fe55efa3ae60506b7802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1b70f914e5ce0fb488d19c0048f53506c1a9c329126385919831e396833db7b867d68db356aa99ff29129b100a1be61c9c70dfa8c4b4c506d5be63a59f5dc6
|
7
|
+
data.tar.gz: 1a5e96394a14b0af13d9e1e388a896bc7d4265b7acee77a7875cef8ca32abc2be9d4c60c645f0207982685a99ecf8e770a6e0aa97ebd7a2a3cb727b53b7da578
|
data/lib/impala/connection.rb
CHANGED
@@ -65,8 +65,8 @@ module Impala
|
|
65
65
|
# except for :user, see TImpalaQueryOptions in ImpalaService.thrift
|
66
66
|
# @option query_options [String] :user the user runs the query
|
67
67
|
# @return [Array<Hash>] an array of hashes, one for each row.
|
68
|
-
def query(
|
69
|
-
execute(
|
68
|
+
def query(query, query_options = {})
|
69
|
+
execute(query, query_options).fetch_all
|
70
70
|
end
|
71
71
|
|
72
72
|
# Perform a query and return a cursor for iterating over the results.
|
@@ -75,29 +75,19 @@ module Impala
|
|
75
75
|
# except for :user, see TImpalaQueryOptions in ImpalaService.thrift
|
76
76
|
# @option query_options [String] :user the user runs the query
|
77
77
|
# @return [Cursor] a cursor for the result rows
|
78
|
-
def execute(
|
78
|
+
def execute(query, query_options = {})
|
79
79
|
raise ConnectionError.new("Connection closed") unless open?
|
80
80
|
|
81
|
-
query = sanitize_query(raw_query)
|
82
81
|
handle = send_query(query, query_options)
|
83
|
-
|
84
82
|
check_result(handle)
|
85
83
|
Cursor.new(handle, @service)
|
86
84
|
end
|
87
85
|
|
88
86
|
private
|
89
87
|
|
90
|
-
def
|
91
|
-
words = raw_query.split
|
92
|
-
raise InvalidQueryError.new("Empty query") if words.empty?
|
93
|
-
|
94
|
-
command = words.first.downcase
|
95
|
-
([command] + words[1..-1]).join(' ')
|
96
|
-
end
|
97
|
-
|
98
|
-
def send_query(sanitized_query, query_options)
|
88
|
+
def send_query(query_text, query_options)
|
99
89
|
query = Protocol::Beeswax::Query.new
|
100
|
-
query.query =
|
90
|
+
query.query = query_text
|
101
91
|
|
102
92
|
query.hadoop_user = query_options.delete(:user) if query_options[:user]
|
103
93
|
query.configuration = query_options.map do |key, value|
|
data/lib/impala/version.rb
CHANGED
data/test/test_impala.rb
CHANGED
@@ -29,22 +29,6 @@ describe 'Impala.connect' do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe Impala::Connection do
|
32
|
-
describe '#sanitize_query' do
|
33
|
-
before do
|
34
|
-
Impala::Connection.any_instance.stubs(:open)
|
35
|
-
@connection = Impala::Connection.new('test', 1234)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should downcase the command but nothing else' do
|
39
|
-
query = 'SELECT blah FROM Blah'
|
40
|
-
assert_equal('select blah FROM Blah', @connection.send(:sanitize_query, query))
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should reject empty or invalid queries' do
|
44
|
-
assert_raises(Impala::InvalidQueryError) { @connection.send(:sanitize_query, '')}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
32
|
describe '#check_result' do
|
49
33
|
before do
|
50
34
|
Impala::Connection.any_instance.stubs(:open)
|
@@ -66,12 +50,12 @@ describe Impala::Connection do
|
|
66
50
|
Impala::Connection.any_instance.stubs(:open)
|
67
51
|
Impala::Cursor.stubs(:new)
|
68
52
|
@connection = Impala::Connection.new('test', 1234)
|
69
|
-
@connection.stubs(:open? => true, :
|
53
|
+
@connection.stubs(:open? => true, :check_result => nil)
|
70
54
|
end
|
71
55
|
|
72
|
-
it 'should call Protocol::ImpalaService::Client#executeAndWait with the
|
56
|
+
it 'should call Protocol::ImpalaService::Client#executeAndWait with the query' do
|
73
57
|
query = Impala::Protocol::Beeswax::Query.new
|
74
|
-
query.query = '
|
58
|
+
query.query = 'query'
|
75
59
|
query.configuration = []
|
76
60
|
|
77
61
|
@service = stub()
|
@@ -83,7 +67,7 @@ describe Impala::Connection do
|
|
83
67
|
|
84
68
|
it 'should call Protocol::ImpalaService::Client#executeAndWait with the hadoop_user and configuration if passed as parameter' do
|
85
69
|
query = Impala::Protocol::Beeswax::Query.new
|
86
|
-
query.query = '
|
70
|
+
query.query = 'query'
|
87
71
|
query.hadoop_user = 'impala'
|
88
72
|
query.configuration = %w|NUM_SCANNER_THREADS=8 MEM_LIMIT=3221225472|
|
89
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: impala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Marc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thrift
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
204
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.4.5.
|
205
|
+
rubygems_version: 2.4.5.2
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: A ruby client for Cloudera's Impala
|