egis 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1ca49c2a770af01b7ff35956785bd77ca5df10446e229620f7cb21892b65e1f
4
- data.tar.gz: 450b5de96addf904a43f7b14bc5b55c3f876c982977e6b8ae51a6e58a0466a04
3
+ metadata.gz: 11391a5ed53240c217c0bdd8db15ddfee6de259341a11f7109475149d7486e52
4
+ data.tar.gz: 117fb43d54ec8363a44c70924cb4e94c194b234a710ec806fd1d9ae0e534d550
5
5
  SHA512:
6
- metadata.gz: f542064733b5d9805a27dd40b4628527e3faf932788f96b7911db0726f729f8f89835c06ba767d5532cab603633838146113ae46dfd8b1089d70ba3288806312
7
- data.tar.gz: d833d875b4cee9b4d435aa0394908b1466ff1588bb9620fe237c72b95e16965ebf34299a8e5a63d1ce70bf1642ebfd053f6089688ffd83320dadcbb10cc2ca8d
6
+ metadata.gz: db5df8ea30e0a55dcd4988859ea13ed5e674491bf545a468630e9fe0821c8c36cd360b2839d13e609e2007bc32b5aa89e3a58870bdcdbbaca6b5cf448ac6d59f
7
+ data.tar.gz: 9aa20b80ff73d128b1f057727fe9ce28367b77500e2c1724d1437b8228d900906f3ec3138d98e8d5c00d11a0e4d1f1674319ddf9fac0c3079ebff7b9b8ca9979
@@ -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 (defaults to :tsv)
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
- #{format_statement(table.format)}
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 format_statement(format)
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 ','"
@@ -43,6 +43,6 @@ module Egis # rubocop:disable Style/Documentation
43
43
  yield
44
44
  ensure
45
45
  @mode = previous_mode
46
- test_mode.cleanup if test_mode
46
+ test_mode&.cleanup
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Egis
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  end
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.2.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-05-29 00:00:00.000000000 Z
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