embulk-input-dynamodb 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/master.yml +34 -0
- data/.github/workflows/test.yml +30 -0
- data/.scalafmt.conf +5 -0
- data/CHANGELOG.md +49 -0
- data/README.md +204 -54
- data/build.gradle +53 -44
- data/example/config-deprecated.yml +20 -0
- data/example/config-query-as-json.yml +18 -0
- data/example/config-query.yml +22 -0
- data/example/config-scan.yml +18 -0
- data/example/prepare_dynamodb_table.sh +67 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +1 -2
- data/gradlew +67 -48
- data/gradlew.bat +20 -10
- data/{test/run_dynamodb_local.sh → run_dynamodb_local.sh} +2 -1
- data/settings.gradle +1 -0
- data/src/main/scala/org/embulk/input/dynamodb/DeprecatedDynamodbInputPlugin.scala +73 -0
- data/src/main/scala/org/embulk/input/dynamodb/DynamodbInputPlugin.scala +76 -25
- data/src/main/scala/org/embulk/input/dynamodb/PluginTask.scala +132 -32
- data/src/main/scala/org/embulk/input/dynamodb/aws/Aws.scala +44 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsClientConfiguration.scala +37 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsCredentials.scala +240 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsDynamodbConfiguration.scala +35 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsEndpointConfiguration.scala +79 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/HttpProxy.scala +61 -0
- data/src/main/scala/org/embulk/input/dynamodb/deprecated/AttributeValueHelper.scala +72 -0
- data/src/main/scala/org/embulk/input/dynamodb/{Filter.scala → deprecated/Filter.scala} +3 -3
- data/src/main/scala/org/embulk/input/dynamodb/{FilterConfig.scala → deprecated/FilterConfig.scala} +13 -13
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/AbstractOperation.scala +36 -18
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/QueryOperation.scala +21 -13
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/ScanOperation.scala +20 -13
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValue.scala +154 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueEmbulkTypeTransformable.scala +245 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueType.scala +33 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemColumnVisitor.scala +50 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemConsumer.scala +40 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemIterator.scala +19 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemReader.scala +64 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemSchema.scala +135 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/AbstractDynamodbOperation.scala +169 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbOperationProxy.scala +59 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbQueryOperation.scala +72 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbScanOperation.scala +93 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/EmbulkDynamodbOperation.scala +15 -0
- data/src/main/scala/org/embulk/input/dynamodb/package.scala +4 -9
- data/src/test/scala/org/embulk/input/dynamodb/AttributeValueHelperTest.scala +245 -101
- data/src/test/scala/org/embulk/input/dynamodb/AwsCredentialsTest.scala +150 -97
- data/src/test/scala/org/embulk/input/dynamodb/DynamodbQueryOperationTest.scala +188 -0
- data/src/test/scala/org/embulk/input/dynamodb/DynamodbScanOperationTest.scala +181 -0
- data/src/test/scala/org/embulk/input/dynamodb/testutil/EmbulkTestBase.scala +85 -0
- metadata +73 -49
- data/circle.yml +0 -16
- data/config/checkstyle/checkstyle.xml +0 -128
- data/config/checkstyle/default.xml +0 -108
- data/src/main/scala/org/embulk/input/dynamodb/AttributeValueHelper.scala +0 -41
- data/src/main/scala/org/embulk/input/dynamodb/AwsCredentials.scala +0 -63
- data/src/main/scala/org/embulk/input/dynamodb/DynamoDBClient.scala +0 -23
- data/src/test/resources/yaml/authMethodBasic.yml +0 -21
- data/src/test/resources/yaml/authMethodBasic_Error.yml +0 -19
- data/src/test/resources/yaml/authMethodEnv.yml +0 -19
- data/src/test/resources/yaml/authMethodProfile.yml +0 -20
- data/src/test/resources/yaml/dynamodb-local-query.yml +0 -25
- data/src/test/resources/yaml/dynamodb-local-scan.yml +0 -23
- data/src/test/resources/yaml/notSetAuthMethod.yml +0 -20
- data/src/test/scala/org/embulk/input/dynamodb/ope/QueryOperationTest.scala +0 -83
- data/src/test/scala/org/embulk/input/dynamodb/ope/ScanOperationTest.scala +0 -83
- data/test/create_table.sh +0 -16
- data/test/put_items.sh +0 -25
@@ -1,20 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
region: ENV_VAR
|
4
|
-
operation: scan
|
5
|
-
table: ENV_VAR
|
6
|
-
auth_method: profile
|
7
|
-
profile_name: ENV_VAR
|
8
|
-
columns:
|
9
|
-
- {name: pri-key, type: string}
|
10
|
-
- {name: sort-key, type: long}
|
11
|
-
- {name: value, type: string}
|
12
|
-
|
13
|
-
out:
|
14
|
-
type: file
|
15
|
-
path_prefix: result
|
16
|
-
file_ext: tsv
|
17
|
-
formatter:
|
18
|
-
type: csv
|
19
|
-
delimiter: "\t"
|
20
|
-
header_line: false
|
@@ -1,25 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
end_point: http://localhost:8000/
|
4
|
-
table: ENV_VAR
|
5
|
-
auth_method: basic
|
6
|
-
access_key: dummy
|
7
|
-
secret_key: dummy
|
8
|
-
filters:
|
9
|
-
- {name: pri-key, type: string, condition: EQ, value: key-1}
|
10
|
-
columns:
|
11
|
-
- {name: pri-key, type: string}
|
12
|
-
- {name: sort-key, type: long}
|
13
|
-
- {name: doubleValue, type: double}
|
14
|
-
- {name: boolValue, type: boolean}
|
15
|
-
- {name: listValue, type: json}
|
16
|
-
- {name: mapValue, type: json}
|
17
|
-
|
18
|
-
out:
|
19
|
-
type: file
|
20
|
-
path_prefix: dynamodb-local-result
|
21
|
-
file_ext: tsv
|
22
|
-
formatter:
|
23
|
-
type: csv
|
24
|
-
delimiter: "\t"
|
25
|
-
header_line: false
|
@@ -1,23 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
end_point: http://localhost:8000/
|
4
|
-
table: ENV_VAR
|
5
|
-
auth_method: basic
|
6
|
-
access_key: dummy
|
7
|
-
secret_key: dummy
|
8
|
-
columns:
|
9
|
-
- {name: pri-key, type: string}
|
10
|
-
- {name: sort-key, type: long}
|
11
|
-
- {name: doubleValue, type: double}
|
12
|
-
- {name: boolValue, type: boolean}
|
13
|
-
- {name: listValue, type: json}
|
14
|
-
- {name: mapValue, type: json}
|
15
|
-
|
16
|
-
out:
|
17
|
-
type: file
|
18
|
-
path_prefix: dynamodb-local-result
|
19
|
-
file_ext: tsv
|
20
|
-
formatter:
|
21
|
-
type: csv
|
22
|
-
delimiter: "\t"
|
23
|
-
header_line: false
|
@@ -1,20 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
region: ENV_VAR
|
4
|
-
operation: scan
|
5
|
-
table: ENV_VAR
|
6
|
-
access_key: ENV_VAR
|
7
|
-
secret_key: ENV_VAR
|
8
|
-
columns:
|
9
|
-
- {name: pri-key, type: string}
|
10
|
-
- {name: sort-key, type: long}
|
11
|
-
- {name: value, type: string}
|
12
|
-
|
13
|
-
out:
|
14
|
-
type: file
|
15
|
-
path_prefix: result
|
16
|
-
file_ext: tsv
|
17
|
-
formatter:
|
18
|
-
type: csv
|
19
|
-
delimiter: "\t"
|
20
|
-
header_line: false
|
@@ -1,83 +0,0 @@
|
|
1
|
-
package org.embulk.input.dynamodb.ope
|
2
|
-
|
3
|
-
import java.io.File
|
4
|
-
import java.nio.charset.Charset
|
5
|
-
import java.nio.file.{FileSystems, Files}
|
6
|
-
|
7
|
-
import com.fasterxml.jackson.databind.ObjectMapper
|
8
|
-
import com.google.inject.{Binder, Module}
|
9
|
-
import org.embulk.EmbulkEmbed
|
10
|
-
import org.embulk.config.ConfigSource
|
11
|
-
import org.embulk.input.dynamodb.DynamodbInputPlugin
|
12
|
-
import org.embulk.plugin.InjectedPluginSource
|
13
|
-
import org.embulk.spi.InputPlugin
|
14
|
-
import org.hamcrest.CoreMatchers._
|
15
|
-
import org.junit.Assert._
|
16
|
-
import org.junit.{Before, Test}
|
17
|
-
|
18
|
-
class QueryOperationTest {
|
19
|
-
private var embulk: EmbulkEmbed = null
|
20
|
-
|
21
|
-
private var EMBULK_DYNAMODB_TEST_TABLE: String = null
|
22
|
-
private var mapper: ObjectMapper = null
|
23
|
-
|
24
|
-
@Before
|
25
|
-
def createResources() {
|
26
|
-
// Get Environments
|
27
|
-
EMBULK_DYNAMODB_TEST_TABLE = System.getenv("EMBULK_DYNAMODB_TEST_TABLE")
|
28
|
-
|
29
|
-
val bootstrap = new EmbulkEmbed.Bootstrap()
|
30
|
-
bootstrap.addModules(new Module {
|
31
|
-
def configure(binder: Binder): Unit = {
|
32
|
-
InjectedPluginSource.registerPluginTo(binder,
|
33
|
-
classOf[InputPlugin],
|
34
|
-
"dynamodb",
|
35
|
-
classOf[DynamodbInputPlugin])
|
36
|
-
}
|
37
|
-
})
|
38
|
-
|
39
|
-
embulk = bootstrap.initializeCloseable()
|
40
|
-
|
41
|
-
mapper = new ObjectMapper()
|
42
|
-
}
|
43
|
-
|
44
|
-
|
45
|
-
def doTest(config: ConfigSource) {
|
46
|
-
embulk.run(config)
|
47
|
-
|
48
|
-
val fs = FileSystems.getDefault
|
49
|
-
val lines = Files.readAllLines(fs.getPath("dynamodb-local-result000.00.tsv"), Charset.forName("UTF-8"))
|
50
|
-
assertEquals(lines.size, 1)
|
51
|
-
|
52
|
-
val head = lines.get(0)
|
53
|
-
val values = head.split("\t")
|
54
|
-
|
55
|
-
assertThat(values(0), is("key-1"))
|
56
|
-
assertThat(values(1), is("0"))
|
57
|
-
assertThat(values(2), is("42.195"))
|
58
|
-
assertThat(values(3), is("true"))
|
59
|
-
|
60
|
-
val listValue = mapper.readValue(values(4).replaceAll("\"(?!\")", ""), classOf[java.util.List[Object]])
|
61
|
-
assertThat(listValue.size(), is(2))
|
62
|
-
assertThat(listValue.get(0).asInstanceOf[String], is("list-value"))
|
63
|
-
assertThat(listValue.get(1).asInstanceOf[Int], is(123))
|
64
|
-
|
65
|
-
val mapValue = mapper.readValue(values(5).replaceAll("\"(?!\")", ""), classOf[java.util.Map[String, Object]])
|
66
|
-
assert(mapValue.containsKey("map-key-1"))
|
67
|
-
assertThat(mapValue.get("map-key-1").asInstanceOf[String], is("map-value-1"))
|
68
|
-
assert(mapValue.containsKey("map-key-2"))
|
69
|
-
assertThat(mapValue.get("map-key-2").asInstanceOf[Int], is(456))
|
70
|
-
}
|
71
|
-
|
72
|
-
@Test
|
73
|
-
def queryTest() {
|
74
|
-
val config = embulk.newConfigLoader().fromYamlFile(
|
75
|
-
new File("src/test/resources/yaml/dynamodb-local-query.yml"))
|
76
|
-
|
77
|
-
config.getNested("in")
|
78
|
-
.set("operation", "query")
|
79
|
-
.set("table", EMBULK_DYNAMODB_TEST_TABLE)
|
80
|
-
|
81
|
-
doTest(config)
|
82
|
-
}
|
83
|
-
}
|
@@ -1,83 +0,0 @@
|
|
1
|
-
package org.embulk.input.dynamodb.ope
|
2
|
-
|
3
|
-
import java.io.File
|
4
|
-
import java.nio.charset.Charset
|
5
|
-
import java.nio.file.{FileSystems, Files}
|
6
|
-
|
7
|
-
import com.fasterxml.jackson.databind.ObjectMapper
|
8
|
-
import com.google.inject.{Binder, Module}
|
9
|
-
import org.embulk.EmbulkEmbed
|
10
|
-
import org.embulk.config.ConfigSource
|
11
|
-
import org.embulk.input.dynamodb.DynamodbInputPlugin
|
12
|
-
import org.embulk.plugin.InjectedPluginSource
|
13
|
-
import org.embulk.spi.InputPlugin
|
14
|
-
import org.hamcrest.CoreMatchers._
|
15
|
-
import org.junit.Assert._
|
16
|
-
import org.junit.{Before, Test}
|
17
|
-
|
18
|
-
class ScanOperationTest {
|
19
|
-
private var embulk: EmbulkEmbed = null
|
20
|
-
|
21
|
-
private var EMBULK_DYNAMODB_TEST_TABLE: String = null
|
22
|
-
private var mapper: ObjectMapper = null
|
23
|
-
|
24
|
-
@Before
|
25
|
-
def createResources() {
|
26
|
-
// Get Environments
|
27
|
-
EMBULK_DYNAMODB_TEST_TABLE = System.getenv("EMBULK_DYNAMODB_TEST_TABLE")
|
28
|
-
|
29
|
-
val bootstrap = new EmbulkEmbed.Bootstrap()
|
30
|
-
bootstrap.addModules(new Module {
|
31
|
-
def configure(binder: Binder): Unit = {
|
32
|
-
InjectedPluginSource.registerPluginTo(binder,
|
33
|
-
classOf[InputPlugin],
|
34
|
-
"dynamodb",
|
35
|
-
classOf[DynamodbInputPlugin])
|
36
|
-
}
|
37
|
-
})
|
38
|
-
|
39
|
-
embulk = bootstrap.initializeCloseable()
|
40
|
-
|
41
|
-
mapper = new ObjectMapper()
|
42
|
-
}
|
43
|
-
|
44
|
-
|
45
|
-
def doTest(config: ConfigSource) {
|
46
|
-
embulk.run(config)
|
47
|
-
|
48
|
-
val fs = FileSystems.getDefault
|
49
|
-
val lines = Files.readAllLines(fs.getPath("dynamodb-local-result000.00.tsv"), Charset.forName("UTF-8"))
|
50
|
-
assertEquals(lines.size, 1)
|
51
|
-
|
52
|
-
val head = lines.get(0)
|
53
|
-
val values = head.split("\t")
|
54
|
-
|
55
|
-
assertThat(values(0), is("key-1"))
|
56
|
-
assertThat(values(1), is("0"))
|
57
|
-
assertThat(values(2), is("42.195"))
|
58
|
-
assertThat(values(3), is("true"))
|
59
|
-
|
60
|
-
val listValue = mapper.readValue(values(4).replaceAll("\"(?!\")", ""), classOf[java.util.List[Object]])
|
61
|
-
assertThat(listValue.size(), is(2))
|
62
|
-
assertThat(listValue.get(0).asInstanceOf[String], is("list-value"))
|
63
|
-
assertThat(listValue.get(1).asInstanceOf[Int], is(123))
|
64
|
-
|
65
|
-
val mapValue = mapper.readValue(values(5).replaceAll("\"(?!\")", ""), classOf[java.util.Map[String, Object]])
|
66
|
-
assert(mapValue.containsKey("map-key-1"))
|
67
|
-
assertThat(mapValue.get("map-key-1").asInstanceOf[String], is("map-value-1"))
|
68
|
-
assert(mapValue.containsKey("map-key-2"))
|
69
|
-
assertThat(mapValue.get("map-key-2").asInstanceOf[Int], is(456))
|
70
|
-
}
|
71
|
-
|
72
|
-
@Test
|
73
|
-
def scanTest() {
|
74
|
-
val config = embulk.newConfigLoader().fromYamlFile(
|
75
|
-
new File("src/test/resources/yaml/dynamodb-local-scan.yml"))
|
76
|
-
|
77
|
-
config.getNested("in")
|
78
|
-
.set("operation", "scan")
|
79
|
-
.set("table", EMBULK_DYNAMODB_TEST_TABLE)
|
80
|
-
|
81
|
-
doTest(config)
|
82
|
-
}
|
83
|
-
}
|
data/test/create_table.sh
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
aws dynamodb create-table \
|
4
|
-
--table-name='EMBULK_DYNAMODB_TEST_TABLE' \
|
5
|
-
--attribute-definitions='[
|
6
|
-
{"AttributeName":"pri-key","AttributeType":"S"},
|
7
|
-
{"AttributeName":"sort-key","AttributeType":"N"}
|
8
|
-
]' \
|
9
|
-
--key-schema='[
|
10
|
-
{"AttributeName":"pri-key","KeyType":"HASH"},
|
11
|
-
{"AttributeName":"sort-key","KeyType":"RANGE"}
|
12
|
-
]' \
|
13
|
-
--provisioned-throughput='{"ReadCapacityUnits":5, "WriteCapacityUnits":5}' \
|
14
|
-
--endpoint-url http://localhost:8000 \
|
15
|
-
--region us-east-1
|
16
|
-
|
data/test/put_items.sh
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
aws dynamodb put-item \
|
4
|
-
--table-name='EMBULK_DYNAMODB_TEST_TABLE' \
|
5
|
-
--item='{
|
6
|
-
"pri-key" : { "S" : "key-1" },
|
7
|
-
"sort-key" : { "N" : "0" },
|
8
|
-
"doubleValue" : { "N" : "42.195" },
|
9
|
-
"boolValue" : { "BOOL" : true },
|
10
|
-
"listValue" : { "L":
|
11
|
-
[
|
12
|
-
{ "S" : "list-value"},
|
13
|
-
{ "N" : "123"}
|
14
|
-
]
|
15
|
-
},
|
16
|
-
"mapValue" : { "M":
|
17
|
-
{
|
18
|
-
"map-key-1" : { "S" : "map-value-1" },
|
19
|
-
"map-key-2" : { "N" : "456" }
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}' \
|
23
|
-
--endpoint-url http://localhost:8000 \
|
24
|
-
--region us-east-1
|
25
|
-
|