hipster_sql_to_hbase 0.1.8 → 0.1.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/hipster_sql_to_hbase.gemspec +1 -1
- data/lib/hipster_sql_to_hbase.rb +28 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b82a138f6e35c5a4072920ba7a5f5b6c07538e1
|
4
|
+
data.tar.gz: cab50297a9a0e006e2034bb99e803cbfb0239625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 721c219f83f84770cc61b7e87ff3f345536168d2a7d2d962d42112ae96d1f1120e766a5fef5865c20db11a4a79ad7779d1bd1f1a4d54b14445d63f06dd70356c
|
7
|
+
data.tar.gz: d58b5d6e8d55ac34abd20e9ce71bd33dd46b38da13818365dd2aa8cd9648962e6de6169201b3cec7b2e8773ad4004474542eca7473000981c92e65d877e14553
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.85
|
data/lib/hipster_sql_to_hbase.rb
CHANGED
@@ -94,6 +94,31 @@ module HipsterSqlToHbase
|
|
94
94
|
HipsterSqlToHbase::SyntaxParser.new.parse(string.squish)
|
95
95
|
end
|
96
96
|
|
97
|
+
# Generate a Hash from a valid, SQL string.
|
98
|
+
#
|
99
|
+
# === example:
|
100
|
+
# HipsterSqlToHbase.parse_hash "SELECT user,password FROM users WHERE id=1"
|
101
|
+
#
|
102
|
+
# === outputs:
|
103
|
+
# {
|
104
|
+
# :query_type=>:select,
|
105
|
+
# :query_hash=>{
|
106
|
+
# :select=>["user", "password"],
|
107
|
+
# :from=>"users",
|
108
|
+
# :where=>[{:column=>"id", :condition=>:"=", :value=>1}],
|
109
|
+
# :limit=>nil,
|
110
|
+
# :order_by=>nil
|
111
|
+
# }
|
112
|
+
# }
|
113
|
+
def parse_hash(string)
|
114
|
+
syntax_tree = parse_syntax(string)
|
115
|
+
return nil if syntax_tree.nil?
|
116
|
+
{
|
117
|
+
:query_type => syntax_tree.query_type,
|
118
|
+
:query_hash => syntax_tree.tree
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
97
122
|
# Generate a <b>HipsterSqlToHbase</b>::<b>ResultTree</b> from a valid, SQL string.
|
98
123
|
#
|
99
124
|
# === example:
|
@@ -110,10 +135,10 @@ module HipsterSqlToHbase
|
|
110
135
|
# :order_by=>nil
|
111
136
|
# }
|
112
137
|
# }
|
138
|
+
#
|
139
|
+
# === Note: the main difference between **parse_tree** and **parse_hash** is that a **ResultTree** can be further converted to Thrift calls while a **Hash** cannot.
|
113
140
|
def parse_tree(string)
|
114
|
-
|
115
|
-
return nil if syntax_tree.nil?
|
116
|
-
HipsterSqlToHbase::ResultTree.new({:query_type => syntax_tree.query_type, :query_hash => syntax_tree.tree})
|
141
|
+
HipsterSqlToHbase::ResultTree.new(parse_hash(string))
|
117
142
|
end
|
118
143
|
|
119
144
|
# Generate a <b>HipsterSqlToHbase</b>::<b>ThriftCallGroup</b> from a valid, SQL string.
|