embulk-formatter-fast_jsonl 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e484178b1ad2c59bcf8174c64e2ab5971ea66c4d
4
- data.tar.gz: 750dafa0093696f5d5dd6dc70adb29ba75a25b43
3
+ metadata.gz: d506f3bbc729a3fbe07de916c993300443ed3f53
4
+ data.tar.gz: c93417de99924a0227d2db91652b16e690abcf1c
5
5
  SHA512:
6
- metadata.gz: 7f87f64eefd47578fbf0f5d3c352ddc9a2297769b0579ae70d434ea107d51ac5f182044dfb7ec6c3791e531a94a569f88bdc492ef5c845d533170ac050a03ec7
7
- data.tar.gz: 89ec108c4f83583bde29bcdd8be5efd4387ea04cabaa6e0a051b1c805740e253cdb7131bab2e8d2c39eaf1bd5738533b04ab79d8e6e56d36daa65c14561efd1a
6
+ metadata.gz: 838f1f2b97e9bec0345ca7b16c691e60e0a7fa43697b0bf4511d3fe17ff3ece745ebae4a0de784f1af416fe62accebce8e27c14f126480ffbddaea44a1b7b22a
7
+ data.tar.gz: 7d85448d372cb567bb494be1f4678733e2417d93ca3f48d6b4cb5d96debd60afd40fcae529191b9664628f249b5d3cea40fa2935712071b5c86664678f2ad011
data/README.md CHANGED
@@ -16,6 +16,9 @@ Format json as 1 json in single line.
16
16
  - **explode_json_columns**: json column's explode to top fields. (array default:[])
17
17
  - **json_columns**: json formatted as string column name. (array default:[])
18
18
 
19
+ ### additional mode
20
+ - **suffix_key**: append suffix of key and value.(map Map[String,String]: {} )
21
+
19
22
  ## Example
20
23
 
21
24
  ```yaml
@@ -26,6 +29,8 @@ out:
26
29
  explode_json_columns:
27
30
  - JSON_COLUMN_1
28
31
  - JSON_COLUMN_2
32
+ suffix_key:
33
+ append_key: append_value
29
34
  ```
30
35
 
31
36
  ## Run Examples
data/build.gradle CHANGED
@@ -13,7 +13,7 @@ configurations {
13
13
  provided
14
14
  }
15
15
 
16
- version = "0.1.0"
16
+ version = "0.1.1"
17
17
 
18
18
  sourceCompatibility = 1.7
19
19
  targetCompatibility = 1.7
@@ -24,6 +24,7 @@ dependencies {
24
24
  compile group: 'io.circe', name: 'circe-core_2.11', version: '0.8.0'
25
25
  compile group: 'io.circe', name: 'circe-generic_2.11', version: '0.8.0'
26
26
  compile group: 'io.circe', name: 'circe-parser_2.11', version: '0.8.0'
27
+ testCompile group: 'org.scalatest', name: 'scalatest_2.11', version: '3.0.1'
27
28
  provided "org.embulk:embulk-core:0.8.22"
28
29
  }
29
30
 
@@ -19,7 +19,8 @@ case class PageOutput(schema: Schema, task: PluginTask, output: FileOutput)
19
19
  val reader: PageReader = new PageReader(schema)
20
20
  val explodeColumns: Seq[String] = task.getExplodeJsonColumns().asScala
21
21
  val jsonColumns: Seq[String] = task.getJsonColumns().asScala
22
- private var opened:Boolean = false
22
+ val suffixKey: Map[String, String] = task.getSuffixKey().asScala.toMap
23
+ private var opened: Boolean = false
23
24
 
24
25
  val timestampFormatter: TimestampFormatter =
25
26
  new TimestampFormatter(task, Optional.absent())
@@ -36,7 +37,8 @@ case class PageOutput(schema: Schema, task: PluginTask, output: FileOutput)
36
37
  ColumnVisitor(reader,
37
38
  timestampFormatter,
38
39
  explodeColumns,
39
- jsonColumns)
40
+ jsonColumns,
41
+ suffixKey)
40
42
  schema.visitColumns(visitor)
41
43
  encoder.addLine(visitor.getLine)
42
44
  }
@@ -21,4 +21,7 @@ trait PluginTask
21
21
  @ConfigDefault("[]")
22
22
  def getJsonColumns(): java.util.List[String]
23
23
 
24
+ @Config("suffix_key")
25
+ @ConfigDefault("{}")
26
+ def getSuffixKey(): java.util.Map[String, String]
24
27
  }
@@ -11,7 +11,8 @@ import org.embulk.spi.{
11
11
  case class ColumnVisitor(reader: PageReader,
12
12
  timestampFormatter: TimestampFormatter,
13
13
  explodeColumns: Seq[String],
14
- jsonColumns: Seq[String])
14
+ jsonColumns: Seq[String],
15
+ suffixKey: Map[String, String])
15
16
  extends EmbulkColumnVisitor {
16
17
  import scala.collection.mutable
17
18
 
@@ -80,6 +81,10 @@ case class ColumnVisitor(reader: PageReader,
80
81
  case (key, json) =>
81
82
  recordMap.put(key, json)
82
83
  }
84
+ suffixKey.foreach {
85
+ case (key, value) =>
86
+ recordMap.put(key, Json.fromString(value))
87
+ }
83
88
  JsonEncoder(recordMap).noSpaces
84
89
  }
85
90
 
@@ -12,7 +12,7 @@ object JsonParser {
12
12
  sys.error(s"could not parse json. $value")
13
13
  }
14
14
 
15
- def toJson(value: String):Json = {
15
+ def toJson(value: String): Json = {
16
16
  parse(value) match {
17
17
  case Right(v) =>
18
18
  v
@@ -24,7 +24,8 @@ class JsonEncoderSpec extends FlatSpec with Matchers {
24
24
  map.put(string, json)
25
25
  }
26
26
  val jsonString = JsonEncoder(map).noSpaces
27
- jsonString should be("{\"salutation\":\"Hey\",\"person\":{\"name\":\"Chris\"},\"exclamationMarks\":3}")
27
+ jsonString should be(
28
+ "{\"salutation\":\"Hey\",\"person\":{\"name\":\"Chris\"},\"exclamationMarks\":3}")
28
29
  }
29
30
 
30
31
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-formatter-fast_jsonl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - smdmts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ files:
80
80
  - classpath/circe-jawn_2.11-0.8.0.jar
81
81
  - classpath/circe-numbers_2.11-0.8.0.jar
82
82
  - classpath/circe-parser_2.11-0.8.0.jar
83
- - classpath/embulk-formatter-fast_jsonl-0.1.0.jar
83
+ - classpath/embulk-formatter-fast_jsonl-0.1.1.jar
84
84
  - classpath/jawn-parser_2.11-0.10.4.jar
85
85
  - classpath/machinist_2.11-0.6.1.jar
86
86
  - classpath/macro-compat_2.11-1.1.1.jar