Skip to content

Commit

Permalink
Merge pull request #38 from trocco-io/add_support_for_expanded_subtable
Browse files Browse the repository at this point in the history
Add support for expanded SUBTABLE
  • Loading branch information
d-hrs authored Mar 28, 2024
2 parents ff92a93 + cc29e2b commit ce7b2d9
Show file tree
Hide file tree
Showing 66 changed files with 2,638 additions and 80 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ kintone output plugin for Embulk stores app records from kintone.
- **guest_space_id**: kintone app belongs to guest space, guest space id is required. (integer, optional)
- **mode**: kintone mode (string, required)
- **update_key**: Column name to set update key (string, required if mode is update or upsert)
- **reduce_key**: Key column name to reduce expanded SUBTABLE (string, optional)
- **sort_columns**: List of columns for sorting input records (array of objects, optional)
- **name**: Column name (string, required)
- **order**: Sort order (string `asc` or `desc`, required)
- **max_sort_tmp_files**: Maximum number of temporary files for sorting input records (integer, default is `1024`)
- **max_sort_memory**: Maximum memory usage for sorting input records (bytes in long, default is the estimated available memory, which is the approximate value of the JVM's current free memory)
- **prefer_nulls**: Whether to set fields to null instead of default value of type when column is null (boolean, default is `false`)
- **ignore_nulls**: Whether to completely ignore fields when column is null (boolean, default is `false`)
- **column_options** advanced: a key-value pairs where key is a column name and value is options for the column.
Expand All @@ -26,6 +32,10 @@ kintone output plugin for Embulk stores app records from kintone.
- `USER_SELECT`, `ORGANIZATION_SELECT`, `GROUP_SELECT`, `FILE`
- **timezone**: timezone to convert into `date` (string, default is `UTC`)
- **val_sep**: Used to specify multiple checkbox values (string, default is `,`)
- **sort_columns**: List of columns for sorting rows in SUBTABLE. Available only if type is `SUBTABLE` (array of objects, optional)
- **name**: Column name (string, required)
- **order**: Sort order (string `asc` or `desc`, required)
- **chunk_size**: Maximum number of records to request at once (integer, default is `100`)

## Example

Expand All @@ -46,6 +56,52 @@ out:
date_time: {field_code: "datetime", type: "DATETIME"}
```
### For reduce expanded SUBTABLE
```yaml
out:
...
reduce_key: id
column_options:
id: {field_code: "id", type: "NUMBER"}
...
table: {field_code: "table", type: "SUBTABLE", sort_columns: [{name: number, order: asc}, {name: text, order: desc}]}
table.number: {field_code: "number_in_table", type: "NUMBER"}
table.text: {field_code: "text_in_table", type: "SINGLE_LINE_TEXT"}
```
#### KINTONE
| Form | Field Code |
| ------------------------- | --------------- |
| Table's own | table |
| NUMBER In Table | number_in_table |
| SINGLE_LINE_TEXT In Table | text_in_table |
#### INPUT CSV
```csv
id,table.number,table.text
1,0,test0
1,1,test1
2,0,test0
```

#### RESULT

ID:1

| NUMBER | SINGLE_LINE_TEXT |
| ------------- | ---------------- |
| 0 | test0 |
| 1 | test1 |

ID:2

| NUMBER | SINGLE_LINE_TEXT |
| ------------- | ---------------- |
| 0 | test0 |

## Build

```
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ targetCompatibility = 1.8

dependencies {
compileOnly "org.embulk:embulk-core:0.9.23"
implementation "com.google.code.externalsortinginjava:externalsortinginjava:0.6.2"
implementation project(path: ":shadow-kintone-java-client", configuration: "shadow")

testImplementation "junit:junit:4.+"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.embulk.output.kintone;

import java.util.List;
import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.Task;
Expand All @@ -18,4 +19,8 @@ public interface KintoneColumnOption extends Task {
@Config("val_sep")
@ConfigDefault("\",\"")
String getValueSeparator();

@Config("sort_columns")
@ConfigDefault("[]")
List<KintoneSortColumn> getSortColumns();
}
Loading

0 comments on commit ce7b2d9

Please sign in to comment.