embulk-input-rethinkdb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/input/rethinkdb/RethinkdbInputPlugin.java +23 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ca030b9fc584a0ae98be06b989981197951dace
|
4
|
+
data.tar.gz: 123d35f231b3ea02d62123f6b69a0840f4fb8e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c4845e091d29f00838c5add36ad2a31d94cc192f0b8de37a4e91a5c522954860f196f90ff04e5e8f60ea94187f48c1ff9187a82df4cb0035fcca3135874e13c
|
7
|
+
data.tar.gz: b7cdd6c44a36dcfbca1347ff2523b2914c375869e6876eb2e41245dd5c77f537c2fc2c390812ef6b5cc2b1cd33e6ee75f20648f598d4de6d137bc3563292704b
|
data/README.md
CHANGED
@@ -19,7 +19,10 @@ RethinkDB input plugin for Embulk loads records from RethinkDB.
|
|
19
19
|
- **user**: database login user name (string, required)
|
20
20
|
- **password**: database login password (string, required)
|
21
21
|
- **cert_file**: path to TLS CA certificate file (string)
|
22
|
-
-
|
22
|
+
- Select whether to write a query or specify only the table
|
23
|
+
- **query**: ReQL to run (string)
|
24
|
+
<br>or<br>
|
25
|
+
- **table**: table from which load data from (string)
|
23
26
|
- **column_name**: column name used in outputs (string, default: `"record"`)
|
24
27
|
|
25
28
|
## ReQL for query option
|
data/build.gradle
CHANGED
@@ -80,10 +80,17 @@ public class RethinkdbInputPlugin
|
|
80
80
|
@ConfigDefault("null")
|
81
81
|
Optional<String> getQuery();
|
82
82
|
|
83
|
+
@Config("table")
|
84
|
+
@ConfigDefault("null")
|
85
|
+
Optional<String> getTable();
|
86
|
+
|
83
87
|
@Config("column_name")
|
84
88
|
@ConfigDefault("\"record\"")
|
85
89
|
String getColumnName();
|
86
90
|
|
91
|
+
String getReql();
|
92
|
+
void setReql(String ast);
|
93
|
+
|
87
94
|
@ConfigInject
|
88
95
|
BufferAllocator getBufferAllocator();
|
89
96
|
}
|
@@ -102,9 +109,21 @@ public class RethinkdbInputPlugin
|
|
102
109
|
if (!(task.getUser().isPresent() && task.getPassword().isPresent())) {
|
103
110
|
throw new ConfigException("user and password are needed");
|
104
111
|
}
|
105
|
-
|
106
|
-
|
112
|
+
|
113
|
+
String reql;
|
114
|
+
if (task.getQuery().isPresent()) {
|
115
|
+
if (task.getTable().isPresent()) {
|
116
|
+
throw new ConfigException("only one of 'table' or 'query' parameter is needed");
|
117
|
+
}
|
118
|
+
reql = String.format("var ast = %s; var res = {ast: ast}; res;", task.getQuery().get());
|
107
119
|
}
|
120
|
+
else {
|
121
|
+
if (!task.getTable().isPresent()) {
|
122
|
+
throw new ConfigException("'table' or 'query' parameter is needed");
|
123
|
+
}
|
124
|
+
reql = String.format("var ast = r.table('%s'); var res = {ast: ast}; res;", task.getTable().get());
|
125
|
+
}
|
126
|
+
task.setReql(reql);
|
108
127
|
|
109
128
|
Schema schema = Schema.builder().add(task.getColumnName(), Types.JSON).build();
|
110
129
|
int taskCount = 1;
|
@@ -141,12 +160,11 @@ public class RethinkdbInputPlugin
|
|
141
160
|
RethinkDB r = RethinkDB.r;
|
142
161
|
ReqlAst ast;
|
143
162
|
try {
|
144
|
-
ast = compileReQL(r, task.
|
163
|
+
ast = compileReQL(r, task.getReql());
|
145
164
|
}
|
146
165
|
catch (final ScriptException se) {
|
147
166
|
throw new ConfigException("ReQL compile error");
|
148
167
|
}
|
149
|
-
|
150
168
|
Connection.Builder builder = r.connection()
|
151
169
|
.hostname(task.getHost())
|
152
170
|
.port(task.getPort())
|
@@ -185,14 +203,13 @@ public class RethinkdbInputPlugin
|
|
185
203
|
return Exec.newConfigDiff();
|
186
204
|
}
|
187
205
|
|
188
|
-
private ReqlAst compileReQL(RethinkDB r, String
|
206
|
+
private ReqlAst compileReQL(RethinkDB r, String reql) throws ScriptException
|
189
207
|
{
|
190
208
|
ScriptEngineManager factory = new ScriptEngineManager();
|
191
209
|
ScriptEngine engine = factory.getEngineByName("nashorn");
|
192
210
|
|
193
211
|
engine.put("r", r);
|
194
212
|
|
195
|
-
String reql = String.format("var ast = %s; var res = {ast: ast}; res;", query);
|
196
213
|
Bindings bindings = (Bindings) engine.eval(reql);
|
197
214
|
|
198
215
|
return (ReqlAst) bindings.get("ast");
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-rethinkdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koji Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ files:
|
|
49
49
|
- LICENSE.txt
|
50
50
|
- README.md
|
51
51
|
- build.gradle
|
52
|
-
- classpath/embulk-input-rethinkdb-0.1.
|
52
|
+
- classpath/embulk-input-rethinkdb-0.1.2.jar
|
53
53
|
- classpath/hamcrest-core-1.1.jar
|
54
54
|
- classpath/json-simple-1.1.1.jar
|
55
55
|
- classpath/junit-4.10.jar
|