egis 1.2.1 → 1.3.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/database.rb +2 -1
- data/lib/egis/table_ddl_generator.rb +25 -2
- data/lib/egis/testing.rb +1 -1
- data/lib/egis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11391a5ed53240c217c0bdd8db15ddfee6de259341a11f7109475149d7486e52
|
4
|
+
data.tar.gz: 117fb43d54ec8363a44c70924cb4e94c194b234a710ec806fd1d9ae0e534d550
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5df8ea30e0a55dcd4988859ea13ed5e674491bf545a468630e9fe0821c8c36cd360b2839d13e609e2007bc32b5aa89e3a58870bdcdbbaca6b5cf448ac6d59f
|
7
|
+
data.tar.gz: 9aa20b80ff73d128b1f057727fe9ce28367b77500e2c1724d1437b8228d900906f3ec3138d98e8d5c00d11a0e4d1f1674319ddf9fac0c3079ebff7b9b8ca9979
|
data/lib/egis/database.rb
CHANGED
@@ -28,7 +28,8 @@ module Egis
|
|
28
28
|
# @param [String] table_name
|
29
29
|
# @param [Egis::TableSchema] table_schema
|
30
30
|
# @param [String] table_location S3 URL with table location (e.g. `s3://s3_bucket/table/location/`)
|
31
|
-
# @param [:tsv, :csv, :orc] format Table format
|
31
|
+
# @param [:tsv, :csv, :orc, {serde: 'SerdeClass', serde_properties: {property: value}}] format Table format
|
32
|
+
# (defaults to :tsv)
|
32
33
|
# @return [Egis::Table]
|
33
34
|
|
34
35
|
def table(table_name, table_schema, table_location, **options)
|
@@ -9,7 +9,7 @@ module Egis
|
|
9
9
|
#{column_definition_sql(table.schema.columns)}
|
10
10
|
)
|
11
11
|
#{partition_statement(table.schema)}
|
12
|
-
#{
|
12
|
+
#{row_format_statement(table.format)}
|
13
13
|
LOCATION '#{table.location}';
|
14
14
|
SQL
|
15
15
|
end
|
@@ -34,7 +34,30 @@ module Egis
|
|
34
34
|
columns.map { |column| "`#{column.name}` #{column.type}" }.join(",\n")
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def serde?(format)
|
38
|
+
format.is_a?(Hash) && format.key?(:serde)
|
39
|
+
end
|
40
|
+
|
41
|
+
def row_format_statement(format)
|
42
|
+
return serde_row_format_statement(format) if serde?(format)
|
43
|
+
|
44
|
+
delimited_row_format_statement(format)
|
45
|
+
end
|
46
|
+
|
47
|
+
def serde_row_format_statement(format)
|
48
|
+
row_format = "ROW FORMAT SERDE '#{format[:serde]}'"
|
49
|
+
return row_format unless format.key?(:serde_properties)
|
50
|
+
|
51
|
+
serde_properties = format[:serde_properties].map { |property, value| "'#{property}' = '#{value}'" }
|
52
|
+
<<-SQL
|
53
|
+
#{row_format}
|
54
|
+
WITH SERDEPROPERTIES (
|
55
|
+
#{serde_properties.join(",\n")}
|
56
|
+
)
|
57
|
+
SQL
|
58
|
+
end
|
59
|
+
|
60
|
+
def delimited_row_format_statement(format)
|
38
61
|
case format
|
39
62
|
when :csv
|
40
63
|
"ROW FORMAT DELIMITED FIELDS TERMINATED BY ','"
|
data/lib/egis/testing.rb
CHANGED
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.3.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: 2020-
|
12
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-athena
|