embulk-filter-row 0.1.1 → 0.1.2
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 +4 -4
- data/.travis.yml +6 -0
- data/CHANGELOG.md +6 -0
- data/README.md +3 -0
- data/build.gradle +3 -1
- data/classpath/embulk-filter-row-0.1.2.jar +0 -0
- data/src/main/java/org/embulk/filter/RowFilterPlugin.java +10 -12
- data/src/main/java/org/embulk/filter/row/BooleanCondition.java +26 -12
- data/src/main/java/org/embulk/filter/row/ConditionFactory.java +1 -0
- data/src/main/java/org/embulk/filter/row/DoubleCondition.java +42 -20
- data/src/main/java/org/embulk/filter/row/LongCondition.java +42 -20
- data/src/main/java/org/embulk/filter/row/StringCondition.java +38 -18
- data/src/main/java/org/embulk/filter/row/TimestampCondition.java +42 -20
- data/src/test/java/org/embulk/filter/row/TestConditionFactory.java +10 -10
- metadata +14 -13
- data/classpath/embulk-filter-row-0.1.1.jar +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b023f1b8f18e5e5e62f7d468144b2ebf93127b7
|
|
4
|
+
data.tar.gz: b90fa6ff510413308a0546cc9346bf19930f34b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13d3939ee6d81004330ae10a71d9ee2e48e7c0b8f5a49e2a1fba7145bad1249d3b5e8cb078977f6051c19497a8d8013edb1688ab5ca5c16e957d139045259e6b
|
|
7
|
+
data.tar.gz: d5aae69cd4a8c87eb66fb3eb4b24d451e7b5d842592b21fc6d19dc285cf3aee4a92dd547c6f844052e89e5c5253bc55e323f73c91941205c49df2089803e2bb2
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Row filter plugin for Embulk
|
|
2
2
|
|
|
3
|
+
[](http://travis-ci.org/sonots/embulk-filter-row)
|
|
4
|
+
|
|
3
5
|
A filter plugin for Embulk to filter out rows
|
|
4
6
|
|
|
5
7
|
## Configuration
|
|
@@ -52,6 +54,7 @@ NOTE: column type is automatically retrieved from input data (inputSchema)
|
|
|
52
54
|
|
|
53
55
|
* Support OR condition
|
|
54
56
|
* It should be better to think using Query engine like [Apache Drill](https://drill.apache.org/) or [Presto](https://prestodb.io/)
|
|
57
|
+
* With them, it is possible to send a query to local files, even to S3 files.
|
|
55
58
|
|
|
56
59
|
## ChangeLog
|
|
57
60
|
|
data/build.gradle
CHANGED
|
Binary file
|
|
@@ -43,8 +43,13 @@ import org.embulk.filter.row.ConditionFactory;
|
|
|
43
43
|
|
|
44
44
|
public class RowFilterPlugin implements FilterPlugin
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
private static final Logger logger = Exec.getLogger(RowFilterPlugin.class);
|
|
47
|
+
|
|
48
|
+
public RowFilterPlugin()
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public interface PluginTask extends Task, TimestampParser.Task
|
|
48
53
|
{
|
|
49
54
|
@Config("conditions")
|
|
50
55
|
public List<ConditionConfig> getConditions();
|
|
@@ -61,20 +66,13 @@ public class RowFilterPlugin implements FilterPlugin
|
|
|
61
66
|
control.run(task.dump(), outputSchema);
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
private final Logger log;
|
|
65
|
-
|
|
66
|
-
public RowFilterPlugin()
|
|
67
|
-
{
|
|
68
|
-
log = Exec.getLogger(RowFilterPlugin.class);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
69
|
@Override
|
|
72
|
-
public PageOutput open(TaskSource taskSource, Schema inputSchema,
|
|
73
|
-
Schema outputSchema, PageOutput output)
|
|
70
|
+
public PageOutput open(TaskSource taskSource, final Schema inputSchema,
|
|
71
|
+
final Schema outputSchema, final PageOutput output)
|
|
74
72
|
{
|
|
75
73
|
PluginTask task = taskSource.loadTask(PluginTask.class);
|
|
76
74
|
|
|
77
|
-
HashMap<String, List<Condition>> conditionMap = new HashMap<String, List<Condition>>();
|
|
75
|
+
final HashMap<String, List<Condition>> conditionMap = new HashMap<String, List<Condition>>();
|
|
78
76
|
for (Column column : outputSchema.getColumns()) {
|
|
79
77
|
String columnName = column.getName();
|
|
80
78
|
conditionMap.put(columnName, new ArrayList<Condition>());
|
|
@@ -4,37 +4,51 @@ public class BooleanCondition implements Condition
|
|
|
4
4
|
{
|
|
5
5
|
private BooleanComparator comparator;
|
|
6
6
|
|
|
7
|
-
@FunctionalInterface
|
|
7
|
+
// @FunctionalInterface
|
|
8
8
|
interface BooleanComparator {
|
|
9
9
|
boolean compare(Boolean subject);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
public BooleanCondition(String operator, Boolean argument, boolean not) {
|
|
13
|
-
BooleanComparator comparator;
|
|
12
|
+
public BooleanCondition(final String operator, final Boolean argument, final boolean not) {
|
|
13
|
+
final BooleanComparator comparator;
|
|
14
14
|
switch (operator.toUpperCase()) {
|
|
15
15
|
case "IS NULL":
|
|
16
|
-
comparator = (
|
|
17
|
-
|
|
16
|
+
comparator = new BooleanComparator() {
|
|
17
|
+
public boolean compare(Boolean subject) {
|
|
18
|
+
return subject == null;
|
|
19
|
+
}
|
|
18
20
|
};
|
|
19
21
|
break;
|
|
20
22
|
case "IS NOT NULL":
|
|
21
|
-
comparator = (
|
|
22
|
-
|
|
23
|
+
comparator = new BooleanComparator() {
|
|
24
|
+
public boolean compare(Boolean subject) {
|
|
25
|
+
return subject != null;
|
|
26
|
+
}
|
|
23
27
|
};
|
|
24
28
|
break;
|
|
25
29
|
case "!=":
|
|
26
|
-
comparator = (
|
|
27
|
-
|
|
30
|
+
comparator = new BooleanComparator() {
|
|
31
|
+
public boolean compare(Boolean subject) {
|
|
32
|
+
return subject == null ? true : !subject.equals(argument);
|
|
33
|
+
}
|
|
28
34
|
};
|
|
29
35
|
break;
|
|
30
36
|
default: // case "==":
|
|
31
|
-
comparator = (
|
|
32
|
-
|
|
37
|
+
comparator = new BooleanComparator() {
|
|
38
|
+
public boolean compare(Boolean subject) {
|
|
39
|
+
return subject == null ? false : subject.equals(argument);
|
|
40
|
+
}
|
|
33
41
|
};
|
|
34
42
|
break;
|
|
35
43
|
}
|
|
36
44
|
this.comparator = comparator;
|
|
37
|
-
if (not)
|
|
45
|
+
if (not) {
|
|
46
|
+
this.comparator = new BooleanComparator() {
|
|
47
|
+
public boolean compare(Boolean subject) {
|
|
48
|
+
return !comparator.compare(subject);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
public boolean compare(Boolean subject) {
|
|
@@ -44,6 +44,7 @@ public class ConditionFactory
|
|
|
44
44
|
this.columnType = column.getType();
|
|
45
45
|
this.conditionConfig = conditionConfig;
|
|
46
46
|
this.operator = conditionConfig.getOperator().get().toUpperCase(); // default: ==
|
|
47
|
+
System.out.println(conditionConfig.getNot().get().getClass());
|
|
47
48
|
this.not = conditionConfig.getNot().get().booleanValue(); // default: false
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -4,57 +4,79 @@ public class DoubleCondition implements Condition
|
|
|
4
4
|
{
|
|
5
5
|
private DoubleComparator comparator;
|
|
6
6
|
|
|
7
|
-
@FunctionalInterface
|
|
7
|
+
// @FunctionalInterface
|
|
8
8
|
interface DoubleComparator {
|
|
9
9
|
boolean compare(Double subject);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
public DoubleCondition(String operator, Double argument, boolean not) {
|
|
13
|
-
DoubleComparator comparator;
|
|
12
|
+
public DoubleCondition(final String operator, final Double argument, final boolean not) {
|
|
13
|
+
final DoubleComparator comparator;
|
|
14
14
|
switch (operator.toUpperCase()) {
|
|
15
15
|
case "IS NULL":
|
|
16
|
-
comparator = (
|
|
17
|
-
|
|
16
|
+
comparator = new DoubleComparator() {
|
|
17
|
+
public boolean compare(Double subject) {
|
|
18
|
+
return subject == null;
|
|
19
|
+
}
|
|
18
20
|
};
|
|
19
21
|
break;
|
|
20
22
|
case "IS NOT NULL":
|
|
21
|
-
comparator = (
|
|
22
|
-
|
|
23
|
+
comparator = new DoubleComparator() {
|
|
24
|
+
public boolean compare(Double subject) {
|
|
25
|
+
return subject != null;
|
|
26
|
+
}
|
|
23
27
|
};
|
|
24
28
|
break;
|
|
25
29
|
case ">":
|
|
26
|
-
comparator = (
|
|
27
|
-
|
|
30
|
+
comparator = new DoubleComparator() {
|
|
31
|
+
public boolean compare(Double subject) {
|
|
32
|
+
return subject == null ? false : subject.compareTo(argument) > 0;
|
|
33
|
+
}
|
|
28
34
|
};
|
|
29
35
|
break;
|
|
30
36
|
case ">=":
|
|
31
|
-
comparator = (
|
|
32
|
-
|
|
37
|
+
comparator = new DoubleComparator() {
|
|
38
|
+
public boolean compare(Double subject) {
|
|
39
|
+
return subject == null ? false : subject.compareTo(argument) >= 0;
|
|
40
|
+
}
|
|
33
41
|
};
|
|
34
42
|
break;
|
|
35
43
|
case "<":
|
|
36
|
-
comparator = (
|
|
37
|
-
|
|
44
|
+
comparator = new DoubleComparator() {
|
|
45
|
+
public boolean compare(Double subject) {
|
|
46
|
+
return subject == null ? false : subject.compareTo(argument) < 0;
|
|
47
|
+
}
|
|
38
48
|
};
|
|
39
49
|
break;
|
|
40
50
|
case "<=":
|
|
41
|
-
comparator = (
|
|
42
|
-
|
|
51
|
+
comparator = new DoubleComparator() {
|
|
52
|
+
public boolean compare(Double subject) {
|
|
53
|
+
return subject == null ? false : subject.compareTo(argument) <= 0;
|
|
54
|
+
}
|
|
43
55
|
};
|
|
44
56
|
break;
|
|
45
57
|
case "!=":
|
|
46
|
-
comparator = (
|
|
47
|
-
|
|
58
|
+
comparator = new DoubleComparator() {
|
|
59
|
+
public boolean compare(Double subject) {
|
|
60
|
+
return subject == null ? true : !subject.equals(argument);
|
|
61
|
+
}
|
|
48
62
|
};
|
|
49
63
|
break;
|
|
50
64
|
default: // case "==":
|
|
51
|
-
comparator = (
|
|
52
|
-
|
|
65
|
+
comparator = new DoubleComparator() {
|
|
66
|
+
public boolean compare(Double subject) {
|
|
67
|
+
return subject == null ? false : subject.equals(argument);
|
|
68
|
+
}
|
|
53
69
|
};
|
|
54
70
|
break;
|
|
55
71
|
}
|
|
56
72
|
this.comparator = comparator;
|
|
57
|
-
if (not)
|
|
73
|
+
if (not) {
|
|
74
|
+
this.comparator = new DoubleComparator() {
|
|
75
|
+
public boolean compare(Double subject) {
|
|
76
|
+
return !comparator.compare(subject);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
58
80
|
}
|
|
59
81
|
|
|
60
82
|
public boolean compare(Double subject) {
|
|
@@ -4,57 +4,79 @@ public class LongCondition implements Condition
|
|
|
4
4
|
{
|
|
5
5
|
private LongComparator comparator;
|
|
6
6
|
|
|
7
|
-
@FunctionalInterface
|
|
7
|
+
// @FunctionalInterface
|
|
8
8
|
interface LongComparator {
|
|
9
9
|
boolean compare(Long subject);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
public LongCondition(String operator, Long argument, boolean not) {
|
|
13
|
-
LongComparator comparator;
|
|
12
|
+
public LongCondition(final String operator, final Long argument, final boolean not) {
|
|
13
|
+
final LongComparator comparator;
|
|
14
14
|
switch (operator.toUpperCase()) {
|
|
15
15
|
case "IS NULL":
|
|
16
|
-
comparator = (
|
|
17
|
-
|
|
16
|
+
comparator = new LongComparator() {
|
|
17
|
+
public boolean compare(Long subject) {
|
|
18
|
+
return subject == null;
|
|
19
|
+
}
|
|
18
20
|
};
|
|
19
21
|
break;
|
|
20
22
|
case "IS NOT NULL":
|
|
21
|
-
comparator = (
|
|
22
|
-
|
|
23
|
+
comparator = new LongComparator() {
|
|
24
|
+
public boolean compare(Long subject) {
|
|
25
|
+
return subject != null;
|
|
26
|
+
}
|
|
23
27
|
};
|
|
24
28
|
break;
|
|
25
29
|
case ">":
|
|
26
|
-
comparator = (
|
|
27
|
-
|
|
30
|
+
comparator = new LongComparator() {
|
|
31
|
+
public boolean compare(Long subject) {
|
|
32
|
+
return subject == null ? false : subject.compareTo(argument) > 0;
|
|
33
|
+
}
|
|
28
34
|
};
|
|
29
35
|
break;
|
|
30
36
|
case ">=":
|
|
31
|
-
comparator = (
|
|
32
|
-
|
|
37
|
+
comparator = new LongComparator() {
|
|
38
|
+
public boolean compare(Long subject) {
|
|
39
|
+
return subject == null ? false : subject.compareTo(argument) >= 0;
|
|
40
|
+
}
|
|
33
41
|
};
|
|
34
42
|
break;
|
|
35
43
|
case "<":
|
|
36
|
-
comparator = (
|
|
37
|
-
|
|
44
|
+
comparator = new LongComparator() {
|
|
45
|
+
public boolean compare(Long subject) {
|
|
46
|
+
return subject == null ? false : subject.compareTo(argument) < 0;
|
|
47
|
+
}
|
|
38
48
|
};
|
|
39
49
|
break;
|
|
40
50
|
case "<=":
|
|
41
|
-
comparator = (
|
|
42
|
-
|
|
51
|
+
comparator = new LongComparator() {
|
|
52
|
+
public boolean compare(Long subject) {
|
|
53
|
+
return subject == null ? false : subject.compareTo(argument) <= 0;
|
|
54
|
+
}
|
|
43
55
|
};
|
|
44
56
|
break;
|
|
45
57
|
case "!=":
|
|
46
|
-
comparator = (
|
|
47
|
-
|
|
58
|
+
comparator = new LongComparator() {
|
|
59
|
+
public boolean compare(Long subject) {
|
|
60
|
+
return subject == null ? true : !subject.equals(argument);
|
|
61
|
+
}
|
|
48
62
|
};
|
|
49
63
|
break;
|
|
50
64
|
default: // case "==":
|
|
51
|
-
comparator = (
|
|
52
|
-
|
|
65
|
+
comparator = new LongComparator() {
|
|
66
|
+
public boolean compare(Long subject) {
|
|
67
|
+
return subject == null ? false : subject.equals(argument);
|
|
68
|
+
}
|
|
53
69
|
};
|
|
54
70
|
break;
|
|
55
71
|
}
|
|
56
72
|
this.comparator = comparator;
|
|
57
|
-
if (not)
|
|
73
|
+
if (not) {
|
|
74
|
+
this.comparator = new LongComparator() {
|
|
75
|
+
public boolean compare(Long subject) {
|
|
76
|
+
return !comparator.compare(subject);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
58
80
|
}
|
|
59
81
|
|
|
60
82
|
public boolean compare(Long subject) {
|
|
@@ -4,55 +4,75 @@ public class StringCondition implements Condition
|
|
|
4
4
|
{
|
|
5
5
|
private StringComparator comparator;
|
|
6
6
|
|
|
7
|
-
@FunctionalInterface
|
|
7
|
+
// @FunctionalInterface
|
|
8
8
|
interface StringComparator {
|
|
9
9
|
boolean compare(String subject);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
public StringCondition(String operator, String argument, boolean not) {
|
|
13
|
-
StringComparator comparator;
|
|
12
|
+
public StringCondition(final String operator, final String argument, final boolean not) {
|
|
13
|
+
final StringComparator comparator;
|
|
14
14
|
switch (operator.toUpperCase()) {
|
|
15
15
|
case "START_WITH":
|
|
16
16
|
case "STARTSWITH":
|
|
17
|
-
comparator = (
|
|
18
|
-
|
|
17
|
+
comparator = new StringComparator() {
|
|
18
|
+
public boolean compare(String subject) {
|
|
19
|
+
return subject == null ? false : subject.startsWith(argument);
|
|
20
|
+
}
|
|
19
21
|
};
|
|
20
22
|
break;
|
|
21
23
|
case "END_WITH":
|
|
22
24
|
case "ENDSWITH":
|
|
23
|
-
comparator = (
|
|
24
|
-
|
|
25
|
+
comparator = new StringComparator() {
|
|
26
|
+
public boolean compare(String subject) {
|
|
27
|
+
return subject == null ? false : subject.endsWith(argument);
|
|
28
|
+
}
|
|
25
29
|
};
|
|
26
30
|
break;
|
|
27
31
|
case "INCLUDE":
|
|
28
32
|
case "CONTAINS":
|
|
29
|
-
comparator = (
|
|
30
|
-
|
|
33
|
+
comparator = new StringComparator() {
|
|
34
|
+
public boolean compare(String subject) {
|
|
35
|
+
return subject == null ? false : subject.contains(argument);
|
|
36
|
+
}
|
|
31
37
|
};
|
|
32
38
|
break;
|
|
33
39
|
case "IS NULL":
|
|
34
|
-
comparator = (
|
|
35
|
-
|
|
40
|
+
comparator = new StringComparator() {
|
|
41
|
+
public boolean compare(String subject) {
|
|
42
|
+
return subject == null;
|
|
43
|
+
}
|
|
36
44
|
};
|
|
37
45
|
break;
|
|
38
46
|
case "IS NOT NULL":
|
|
39
|
-
comparator = (
|
|
40
|
-
|
|
47
|
+
comparator = new StringComparator() {
|
|
48
|
+
public boolean compare(String subject) {
|
|
49
|
+
return subject != null;
|
|
50
|
+
}
|
|
41
51
|
};
|
|
42
52
|
break;
|
|
43
53
|
case "!=":
|
|
44
|
-
comparator = (
|
|
45
|
-
|
|
54
|
+
comparator = new StringComparator() {
|
|
55
|
+
public boolean compare(String subject) {
|
|
56
|
+
return subject == null ? true : !subject.equals(argument);
|
|
57
|
+
}
|
|
46
58
|
};
|
|
47
59
|
break;
|
|
48
60
|
default: // case "==":
|
|
49
|
-
comparator = (
|
|
50
|
-
|
|
61
|
+
comparator = new StringComparator() {
|
|
62
|
+
public boolean compare(String subject) {
|
|
63
|
+
return subject == null ? false : subject.equals(argument);
|
|
64
|
+
}
|
|
51
65
|
};
|
|
52
66
|
break;
|
|
53
67
|
}
|
|
54
68
|
this.comparator = comparator;
|
|
55
|
-
if (not)
|
|
69
|
+
if (not) {
|
|
70
|
+
this.comparator = new StringComparator() {
|
|
71
|
+
public boolean compare(String subject) {
|
|
72
|
+
return !comparator.compare(subject);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
public boolean compare(String subject) {
|
|
@@ -5,57 +5,79 @@ public class TimestampCondition implements Condition
|
|
|
5
5
|
{
|
|
6
6
|
private TimestampComparator comparator;
|
|
7
7
|
|
|
8
|
-
@FunctionalInterface
|
|
8
|
+
// @FunctionalInterface
|
|
9
9
|
interface TimestampComparator {
|
|
10
10
|
boolean compare(Timestamp subject);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
public TimestampCondition(String operator, Timestamp argument, boolean not) {
|
|
14
|
-
TimestampComparator comparator;
|
|
13
|
+
public TimestampCondition(final String operator, final Timestamp argument, final boolean not) {
|
|
14
|
+
final TimestampComparator comparator;
|
|
15
15
|
switch (operator.toUpperCase()) {
|
|
16
16
|
case ">":
|
|
17
|
-
comparator = (
|
|
18
|
-
|
|
17
|
+
comparator = new TimestampComparator() {
|
|
18
|
+
public boolean compare(Timestamp subject) {
|
|
19
|
+
return subject == null ? false : subject.compareTo(argument) > 0;
|
|
20
|
+
}
|
|
19
21
|
};
|
|
20
22
|
break;
|
|
21
23
|
case ">=":
|
|
22
|
-
comparator = (
|
|
23
|
-
|
|
24
|
+
comparator = new TimestampComparator() {
|
|
25
|
+
public boolean compare(Timestamp subject) {
|
|
26
|
+
return subject == null ? false : subject.compareTo(argument) >= 0;
|
|
27
|
+
}
|
|
24
28
|
};
|
|
25
29
|
break;
|
|
26
30
|
case "<":
|
|
27
|
-
comparator = (
|
|
28
|
-
|
|
31
|
+
comparator = new TimestampComparator() {
|
|
32
|
+
public boolean compare(Timestamp subject) {
|
|
33
|
+
return subject == null ? false : subject.compareTo(argument) < 0;
|
|
34
|
+
}
|
|
29
35
|
};
|
|
30
36
|
break;
|
|
31
37
|
case "<=":
|
|
32
|
-
comparator = (
|
|
33
|
-
|
|
38
|
+
comparator = new TimestampComparator() {
|
|
39
|
+
public boolean compare(Timestamp subject) {
|
|
40
|
+
return subject == null ? false : subject.compareTo(argument) <= 0;
|
|
41
|
+
}
|
|
34
42
|
};
|
|
35
43
|
break;
|
|
36
44
|
case "IS NULL":
|
|
37
|
-
comparator = (
|
|
38
|
-
|
|
45
|
+
comparator = new TimestampComparator() {
|
|
46
|
+
public boolean compare(Timestamp subject) {
|
|
47
|
+
return subject == null;
|
|
48
|
+
}
|
|
39
49
|
};
|
|
40
50
|
break;
|
|
41
51
|
case "IS NOT NULL":
|
|
42
|
-
comparator = (
|
|
43
|
-
|
|
52
|
+
comparator = new TimestampComparator() {
|
|
53
|
+
public boolean compare(Timestamp subject) {
|
|
54
|
+
return subject != null;
|
|
55
|
+
}
|
|
44
56
|
};
|
|
45
57
|
break;
|
|
46
58
|
case "!=":
|
|
47
|
-
comparator = (
|
|
48
|
-
|
|
59
|
+
comparator = new TimestampComparator() {
|
|
60
|
+
public boolean compare(Timestamp subject) {
|
|
61
|
+
return subject == null ? true : !subject.equals(argument);
|
|
62
|
+
}
|
|
49
63
|
};
|
|
50
64
|
break;
|
|
51
65
|
default: // case "==":
|
|
52
|
-
comparator = (
|
|
53
|
-
|
|
66
|
+
comparator = new TimestampComparator() {
|
|
67
|
+
public boolean compare(Timestamp subject) {
|
|
68
|
+
return subject == null ? false : subject.equals(argument);
|
|
69
|
+
}
|
|
54
70
|
};
|
|
55
71
|
break;
|
|
56
72
|
}
|
|
57
73
|
this.comparator = comparator;
|
|
58
|
-
if (not)
|
|
74
|
+
if (not) {
|
|
75
|
+
this.comparator = new TimestampComparator() {
|
|
76
|
+
public boolean compare(Timestamp subject) {
|
|
77
|
+
return !comparator.compare(subject);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
public boolean compare(Timestamp subject) {
|
|
@@ -71,14 +71,14 @@ public class TestConditionFactory
|
|
|
71
71
|
|
|
72
72
|
config = new DefaultConditionConfig() {
|
|
73
73
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
74
|
-
public Optional<Object> getArgument() { return Optional.of(new Boolean(true)); }
|
|
74
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Boolean(true)); }
|
|
75
75
|
};
|
|
76
76
|
condition = (BooleanCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
77
77
|
assertTrue(condition.compare(new Boolean(true)));
|
|
78
78
|
|
|
79
79
|
config = new DefaultConditionConfig() {
|
|
80
80
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
81
|
-
public Optional<Object> getArgument() { return Optional.of(new Long(10)); }
|
|
81
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Long(10)); }
|
|
82
82
|
};
|
|
83
83
|
try {
|
|
84
84
|
condition = (BooleanCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
@@ -111,14 +111,14 @@ public class TestConditionFactory
|
|
|
111
111
|
|
|
112
112
|
config = new DefaultConditionConfig() {
|
|
113
113
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
114
|
-
public Optional<Object> getArgument() { return Optional.of(new Double(10)); }
|
|
114
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Double(10)); }
|
|
115
115
|
};
|
|
116
116
|
condition = (DoubleCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
117
117
|
assertTrue(condition.compare(new Double(10)));
|
|
118
118
|
|
|
119
119
|
config = new DefaultConditionConfig() {
|
|
120
120
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
121
|
-
public Optional<Object> getArgument() { return Optional.of(new Boolean(true)); }
|
|
121
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Boolean(true)); }
|
|
122
122
|
};
|
|
123
123
|
try {
|
|
124
124
|
condition = (DoubleCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
@@ -151,14 +151,14 @@ public class TestConditionFactory
|
|
|
151
151
|
|
|
152
152
|
config = new DefaultConditionConfig() {
|
|
153
153
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
154
|
-
public Optional<Object> getArgument() { return Optional.of(new Long(10)); }
|
|
154
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Long(10)); }
|
|
155
155
|
};
|
|
156
156
|
condition = (LongCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
157
157
|
assertTrue(condition.compare(new Long(10)));
|
|
158
158
|
|
|
159
159
|
config = new DefaultConditionConfig() {
|
|
160
160
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
161
|
-
public Optional<Object> getArgument() { return Optional.of(new Boolean(true)); }
|
|
161
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Boolean(true)); }
|
|
162
162
|
};
|
|
163
163
|
try {
|
|
164
164
|
condition = (LongCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
@@ -191,14 +191,14 @@ public class TestConditionFactory
|
|
|
191
191
|
|
|
192
192
|
config = new DefaultConditionConfig() {
|
|
193
193
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
194
|
-
public Optional<Object> getArgument() { return Optional.of("foo"); }
|
|
194
|
+
public Optional<Object> getArgument() { return Optional.of((Object)"foo"); }
|
|
195
195
|
};
|
|
196
196
|
condition = (StringCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
197
197
|
assertTrue(condition.compare("foo"));
|
|
198
198
|
|
|
199
199
|
config = new DefaultConditionConfig() {
|
|
200
200
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
201
|
-
public Optional<Object> getArgument() { return Optional.of(new Boolean(true)); }
|
|
201
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Boolean(true)); }
|
|
202
202
|
};
|
|
203
203
|
try {
|
|
204
204
|
condition = (StringCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
@@ -232,14 +232,14 @@ public class TestConditionFactory
|
|
|
232
232
|
//ToDo: How to create jruby object correctly?
|
|
233
233
|
//config = new DefaultConditionConfig() {
|
|
234
234
|
// public Optional<String> getOperator() { return Optional.of("=="); }
|
|
235
|
-
// public Optional<Object> getArgument() { return Optional.of("2015-07-15"); }
|
|
235
|
+
// public Optional<Object> getArgument() { return Optional.of((Object)"2015-07-15"); }
|
|
236
236
|
// public Optional<String> getFormat() { return Optional.of("%Y-%m-%d"); }
|
|
237
237
|
//};
|
|
238
238
|
//condition = (TimestampCondition)new ConditionFactory(jruby, column, config).createCondition();
|
|
239
239
|
|
|
240
240
|
config = new DefaultConditionConfig() {
|
|
241
241
|
public Optional<String> getOperator() { return Optional.of("=="); }
|
|
242
|
-
public Optional<Object> getArgument() { return Optional.of(new Boolean(true)); }
|
|
242
|
+
public Optional<Object> getArgument() { return Optional.of((Object)new Boolean(true)); }
|
|
243
243
|
};
|
|
244
244
|
try {
|
|
245
245
|
condition = (TimestampCondition)new ConditionFactory(jruby, column, config).createCondition();
|
metadata
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: embulk-filter-row
|
|
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
|
- Naotoshi Seo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-07-
|
|
11
|
+
date: 2015-07-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
|
|
14
|
+
name: bundler
|
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
15
16
|
requirements:
|
|
16
17
|
- - ~>
|
|
17
18
|
- !ruby/object:Gem::Version
|
|
18
19
|
version: '1.0'
|
|
19
|
-
|
|
20
|
-
prerelease: false
|
|
21
|
-
type: :development
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
|
23
21
|
requirements:
|
|
24
22
|
- - ~>
|
|
25
23
|
- !ruby/object:Gem::Version
|
|
26
24
|
version: '1.0'
|
|
25
|
+
prerelease: false
|
|
26
|
+
type: :development
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
|
|
28
|
+
name: rake
|
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
29
30
|
requirements:
|
|
30
31
|
- - '>='
|
|
31
32
|
- !ruby/object:Gem::Version
|
|
32
33
|
version: '10.0'
|
|
33
|
-
|
|
34
|
-
prerelease: false
|
|
35
|
-
type: :development
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
|
37
35
|
requirements:
|
|
38
36
|
- - '>='
|
|
39
37
|
- !ruby/object:Gem::Version
|
|
40
38
|
version: '10.0'
|
|
39
|
+
prerelease: false
|
|
40
|
+
type: :development
|
|
41
41
|
description: A filter plugin for Embulk to filter out rows with conditions.
|
|
42
42
|
email:
|
|
43
43
|
- sonots@gmail.com
|
|
@@ -46,6 +46,7 @@ extensions: []
|
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
48
|
- .gitignore
|
|
49
|
+
- .travis.yml
|
|
49
50
|
- CHANGELOG.md
|
|
50
51
|
- LICENSE.txt
|
|
51
52
|
- README.md
|
|
@@ -72,7 +73,7 @@ files:
|
|
|
72
73
|
- src/test/java/org/embulk/filter/row/TestLongCondition.java
|
|
73
74
|
- src/test/java/org/embulk/filter/row/TestStringCondition.java
|
|
74
75
|
- src/test/java/org/embulk/filter/row/TestTimestampCondition.java
|
|
75
|
-
- classpath/embulk-filter-row-0.1.
|
|
76
|
+
- classpath/embulk-filter-row-0.1.2.jar
|
|
76
77
|
homepage: https://github.com/sonots/embulk-filter-row
|
|
77
78
|
licenses:
|
|
78
79
|
- MIT
|
|
Binary file
|