egis 1.3.0 → 1.4.0
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/egis/table.rb +29 -7
- data/lib/egis/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fa3323e3c02d8537df83f33799f580fb196c255315c9923eb70c0e87bd1f50e
|
4
|
+
data.tar.gz: 9b4054a2201d98f501603cc137c1c7df93fccf105c448b6d4261515c3f53d959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3da9b098de6948b584244db63eda8ef4ba3d26ff29806be0e1a3b3469a321bb72d0761bc4bcb415759646a2397c71d32221477cc2dabeb9233dd8cad22300cef
|
7
|
+
data.tar.gz: 5c50463ef9585563b3aa6fefbb89b4df101f93693b7e5d5f423e98fa803e614d7541639db9afe06fc1a4544205d6e3b0cbf3c166112f556f58b8c798b528571d
|
data/lib/egis/table.rb
CHANGED
@@ -97,7 +97,19 @@ module Egis
|
|
97
97
|
##
|
98
98
|
# Insert data into the table. Mostly useful for testing purposes.
|
99
99
|
#
|
100
|
-
# @
|
100
|
+
# @example Insert with array of arrays
|
101
|
+
# table.upload_data([
|
102
|
+
# ['hello world', 'mx', 1],
|
103
|
+
# ['hello again', 'us', 2]
|
104
|
+
# ])
|
105
|
+
#
|
106
|
+
# @example Insert with array of hashes
|
107
|
+
# table.upload_data([
|
108
|
+
# {message: 'hello world', country: 'mx', type: 1},
|
109
|
+
# {message: 'hello again', country: 'us', type: 2}
|
110
|
+
# ])
|
111
|
+
#
|
112
|
+
# @param [Array] rows Array of arrays or hashes with row values
|
101
113
|
# @return [void]
|
102
114
|
|
103
115
|
def upload_data(rows)
|
@@ -149,23 +161,33 @@ module Egis
|
|
149
161
|
Egis.logger.info { "Creating table #{database.name}.#{name} located in #{location}" }
|
150
162
|
end
|
151
163
|
|
152
|
-
def
|
153
|
-
|
164
|
+
def column_types
|
165
|
+
all_columns.map(&:type)
|
154
166
|
end
|
155
167
|
|
156
|
-
def
|
157
|
-
|
168
|
+
def all_columns
|
169
|
+
schema.columns + schema.partitions
|
158
170
|
end
|
159
171
|
|
160
172
|
def data_insert_query(rows)
|
173
|
+
insert_values = rows.map { |row| row_literal_values(row) }
|
174
|
+
row_clause = insert_values.map { |row| row_values_statement(row) }.join(",\n")
|
175
|
+
|
161
176
|
<<~SQL
|
162
177
|
INSERT INTO #{name} VALUES
|
163
|
-
#{
|
178
|
+
#{row_clause}
|
164
179
|
SQL
|
165
180
|
end
|
166
181
|
|
182
|
+
def row_literal_values(row)
|
183
|
+
all_columns.map.with_index do |column, index|
|
184
|
+
value = row.is_a?(Hash) ? row[column.name] : row[index]
|
185
|
+
Egis::Types.serializer(column.type).literal(value)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
167
189
|
def row_values_statement(row)
|
168
|
-
"(#{row.
|
190
|
+
"(#{row.join(', ')})"
|
169
191
|
end
|
170
192
|
end
|
171
193
|
end
|
data/lib/egis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agnieszka Czereba
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-athena
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
|
-
rubygems_version: 3.1.
|
102
|
+
rubygems_version: 3.1.4
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: A handy wrapper for AWS Athena Ruby SDK.
|