sequel-hive-adapter 0.2.2 → 0.2.3
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.
- data/VERSION +1 -1
- data/lib/sequel/adapters/hive.rb +18 -8
- data/sequel-hive-adapter.gemspec +2 -2
- data/spec/sequel-hive-adapter_spec.rb +14 -2
- data/spec/spec_helper.rb +1 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/sequel/adapters/hive.rb
CHANGED
@@ -56,26 +56,32 @@ module Sequel
|
|
56
56
|
|
57
57
|
def columns
|
58
58
|
return @columns if @columns
|
59
|
-
if
|
59
|
+
if needs_schema_check?
|
60
60
|
@columns = schema.map{|c| c.first.to_sym}
|
61
61
|
else
|
62
|
-
@columns = @opts[:select]
|
62
|
+
@columns = @opts[:select].map do |col|
|
63
|
+
col.respond_to?(:aliaz) ? col.aliaz : col
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
68
|
def convert_type(column)
|
67
|
-
return :to_s
|
68
|
-
db_type = schema.select
|
69
|
+
return :to_s unless needs_schema_check?
|
70
|
+
db_type = schema.select do |a|
|
71
|
+
a.first == columns
|
72
|
+
end.first.last[:db_type]
|
69
73
|
CONVERT_FROM[db_type]
|
70
74
|
end
|
71
|
-
|
75
|
+
|
72
76
|
def fetch_rows(sql)
|
73
77
|
execute(sql) do |result|
|
74
78
|
begin
|
75
79
|
width = result.first.size
|
76
80
|
result.each do |r|
|
77
81
|
row = {}
|
78
|
-
r.each_with_index
|
82
|
+
r.each_with_index do |v, i|
|
83
|
+
row[columns[i]] = v.send(convert_type(columns[i]))
|
84
|
+
end
|
79
85
|
yield row
|
80
86
|
end
|
81
87
|
ensure
|
@@ -84,9 +90,13 @@ module Sequel
|
|
84
90
|
end
|
85
91
|
self
|
86
92
|
end
|
87
|
-
|
93
|
+
|
88
94
|
private
|
89
|
-
|
95
|
+
|
96
|
+
def needs_schema_check?
|
97
|
+
@opts[:select].nil? || @opts[:select].include?(:*)
|
98
|
+
end
|
99
|
+
|
90
100
|
def select_clause_methods
|
91
101
|
SELECT_CLAUSE_METHODS
|
92
102
|
end
|
data/sequel-hive-adapter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sequel-hive-adapter}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["hrp"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-10}
|
13
13
|
s.description = %q{A Hadoop Hive adapter for Sequel. Uses RBHive and Thrift.}
|
14
14
|
s.email = %q{hrparmar@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,8 +1,20 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "SequelHiveAdapter" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
TEST_HOST = "localhost"
|
7
|
+
@testdb = Sequel.connect("hive://#{TEST_HOST}")
|
8
|
+
@testtable = 'test_test_test'
|
9
|
+
end
|
10
|
+
|
4
11
|
it "should load" do
|
5
|
-
Sequel
|
6
|
-
|
12
|
+
@testdb.should be_an_instance_of Sequel::Hive::Database
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should convert string columns to strings" do
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should handle group and count" do
|
7
19
|
end
|
8
20
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
|
-
require 'sequel
|
4
|
+
require 'sequel'
|
5
5
|
|
6
6
|
# Requires supporting files with custom matchers and macros, etc,
|
7
7
|
# in ./support/ and its subdirectories.
|
8
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
|
-
|
12
11
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sequel-hive-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- hrp
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-10 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sequel
|
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
139
|
+
hash: 350704082683277980
|
140
140
|
segments:
|
141
141
|
- 0
|
142
142
|
version: "0"
|