rbhive 0.2.7 → 0.2.8

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.
Files changed (2) hide show
  1. data/lib/rbhive/schema_definition.rb +13 -1
  2. metadata +26 -50
@@ -20,7 +20,19 @@ module RBHive
20
20
 
21
21
  def column_names
22
22
  @column_names ||= begin
23
- schema_names = @schema.fieldSchemas.map {|c| c.name.to_sym }
23
+ schema_names = @schema.fieldSchemas.map {|c| c.name }
24
+
25
+ # In rare cases Hive can return two identical column names
26
+ # consider SELECT a.foo, b.foo...
27
+ # in this case you get two columns called foo with no disambiguation.
28
+ # as a (far from ideal) solution we detect this edge case and rename them
29
+ # a.foo => foo1, b.foo => foo2
30
+ # otherwise we will trample one of the columns during Hash mapping.
31
+ s = Hash.new(0)
32
+ schema_names.map! { |c| s[c] += 1; s[c] > 1 ? "#{c}---|---#{s[c]}" : c }
33
+ schema_names.map! { |c| s[c] > 1 ? "#{c}---|---1" : c }
34
+ schema_names.map! { |c| c.gsub('---|---', '_').to_sym }
35
+
24
36
  # Lets fix the fact that Hive doesn't return schema data for partitions on SELECT * queries
25
37
  # For now we will call them :_p1, :_p2, etc. to avoid collisions.
26
38
  offset = 0
metadata CHANGED
@@ -1,47 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rbhive
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.8
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 7
10
- version: 0.2.7
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Forward Internet Group
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-12-07 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2010-12-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: thrift
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70241606819180 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 0
31
- - 4
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.4.0
34
22
  type: :runtime
35
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: *70241606819180
36
25
  description: Simple lib for executing Hive queries
37
26
  email: andy@forward.co.uk
38
27
  executables: []
39
-
40
28
  extensions: []
41
-
42
29
  extra_rdoc_files: []
43
-
44
- files:
30
+ files:
45
31
  - lib/rbhive.rb
46
32
  - lib/rbhive/connection.rb
47
33
  - lib/rbhive/table_schema.rb
@@ -65,36 +51,26 @@ files:
65
51
  - lib/thrift/thrift_hive_metastore.rb
66
52
  homepage: http://github.com/forward/rbhive
67
53
  licenses: []
68
-
69
54
  post_install_message:
70
55
  rdoc_options: []
71
-
72
- require_paths:
56
+ require_paths:
73
57
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
75
59
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
65
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
92
70
  requirements: []
93
-
94
71
  rubyforge_project:
95
- rubygems_version: 1.7.2
72
+ rubygems_version: 1.8.11
96
73
  signing_key:
97
74
  specification_version: 3
98
75
  summary: Simple lib for executing Hive queries
99
76
  test_files: []
100
-