schema-inference 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schema/inference/schema_inferrer.rb +11 -2
- data/lib/schema/inference/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e783c172078cf4000dc5efabd8d5ad85cc3072ff
|
4
|
+
data.tar.gz: b84bdc0aa7c1cfaec9e6228f70c60e070fffe30f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9157d2db16ed2b70a6d731f11d363e976a914635dffe32fe1a750576890e3cca675ef844bb34c48ffce19696d7fc7d3826f3e82696a0c5549d5d63176359d950
|
7
|
+
data.tar.gz: b97153fe64406c10783f28d90e94e3f66a246138c4abeb2bb002cb359f807a211215ca16f6068d74fc74346c3a801eabb354c21c9f42271dc4c48fadc262845b
|
@@ -3,8 +3,9 @@ module Schema
|
|
3
3
|
class SchemaInferrer
|
4
4
|
attr_accessor :separator
|
5
5
|
|
6
|
-
def initialize(separator: '.')
|
6
|
+
def initialize(separator: '.', convert_types_to_string: false)
|
7
7
|
@separator = separator
|
8
|
+
@convert_types_to_string = convert_types_to_string
|
8
9
|
end
|
9
10
|
|
10
11
|
# Generate a schema based on this collection's records.
|
@@ -148,7 +149,7 @@ module Schema
|
|
148
149
|
table_schema[k][:usage] = table_schema[k][:usage_count] / total_count.to_f
|
149
150
|
}
|
150
151
|
|
151
|
-
table_schema
|
152
|
+
@convert_types_to_string ? convert_types_to_string(table_schema) : table_schema
|
152
153
|
end
|
153
154
|
|
154
155
|
NumericTypes = [Numeric, Integer].freeze
|
@@ -232,6 +233,14 @@ module Schema
|
|
232
233
|
(/^[+-]?[0-9]+$/ =~ value).present?
|
233
234
|
end
|
234
235
|
|
236
|
+
def convert_types_to_string(schema)
|
237
|
+
schema.each { |k, v|
|
238
|
+
schema[k][:type] = schema[k][:type].to_s.downcase
|
239
|
+
schema[k][:types] = schema[k][:types].map { |k1,v1| [k1.to_s.downcase, v1] }.to_h
|
240
|
+
}
|
241
|
+
schema
|
242
|
+
end
|
243
|
+
|
235
244
|
def parallel_map(itr, &block)
|
236
245
|
# set to true to debug code in the iteration
|
237
246
|
is_debugging_impl = ENV['DEBUG']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema-inference
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eurico Doirado
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|