embulk-filter-row 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +7 -1
- data/build.gradle +6 -1
- data/classpath/embulk-filter-row-0.2.1.jar +0 -0
- data/config/checkstyle/checkstyle.xml +127 -0
- data/example/example.csv +100 -0
- data/settings.gradle +1 -0
- data/src/main/java/org/embulk/filter/RowFilterPlugin.java +226 -115
- data/src/main/java/org/embulk/filter/row/BooleanCondition.java +16 -8
- data/src/main/java/org/embulk/filter/row/ConditionConfig.java +1 -1
- data/src/main/java/org/embulk/filter/row/ConditionFactory.java +20 -28
- data/src/main/java/org/embulk/filter/row/DoubleCondition.java +24 -12
- data/src/main/java/org/embulk/filter/row/LongCondition.java +31 -18
- data/src/main/java/org/embulk/filter/row/StringCondition.java +22 -11
- data/src/main/java/org/embulk/filter/row/TimestampCondition.java +24 -12
- data/src/test/java/org/embulk/filter/row/TestBooleanCondition.java +13 -7
- data/src/test/java/org/embulk/filter/row/TestConditionFactory.java +232 -95
- data/src/test/java/org/embulk/filter/row/TestDoubleCondition.java +44 -20
- data/src/test/java/org/embulk/filter/row/TestLongCondition.java +100 -27
- data/src/test/java/org/embulk/filter/row/TestStringCondition.java +36 -24
- data/src/test/java/org/embulk/filter/row/TestTimestampCondition.java +31 -21
- metadata +6 -3
- data/classpath/embulk-filter-row-0.2.0.jar +0 -0
@@ -1,30 +1,34 @@
|
|
1
1
|
package org.embulk.filter.row;
|
2
2
|
|
3
|
-
import org.embulk.filter.row.LongCondition;
|
4
3
|
import org.junit.Test;
|
5
|
-
|
4
|
+
|
5
|
+
import static org.junit.Assert.assertFalse;
|
6
|
+
import static org.junit.Assert.assertTrue;
|
6
7
|
|
7
8
|
public class TestLongCondition
|
8
9
|
{
|
9
10
|
@Test
|
10
|
-
public void testIsNull()
|
11
|
+
public void testIsNull()
|
12
|
+
{
|
11
13
|
LongCondition condition = new LongCondition("IS NULL", null, false);
|
12
14
|
assertTrue(condition.compare(null));
|
13
15
|
assertFalse(condition.compare(new Long(10)));
|
14
16
|
}
|
15
17
|
|
16
18
|
@Test
|
17
|
-
public void testIsNotNull()
|
19
|
+
public void testIsNotNull()
|
20
|
+
{
|
18
21
|
LongCondition condition = new LongCondition("IS NOT NULL", null, false);
|
19
22
|
assertFalse(condition.compare(null));
|
20
23
|
assertTrue(condition.compare(new Long(10)));
|
21
24
|
}
|
22
25
|
|
23
26
|
@Test
|
24
|
-
public void testEquals()
|
25
|
-
|
27
|
+
public void testEquals()
|
28
|
+
{
|
29
|
+
LongCondition condition = new LongCondition("==", new Double(10), false);
|
26
30
|
assertFalse(condition.compare(null));
|
27
|
-
assertTrue(
|
31
|
+
assertTrue(condition.compare(new Long(10)));
|
28
32
|
assertFalse(condition.compare(new Long(11)));
|
29
33
|
|
30
34
|
// Prohibited by Factory
|
@@ -32,50 +36,119 @@ public class TestLongCondition
|
|
32
36
|
}
|
33
37
|
|
34
38
|
@Test
|
35
|
-
public void testNotEquals()
|
36
|
-
|
37
|
-
|
39
|
+
public void testNotEquals()
|
40
|
+
{
|
41
|
+
LongCondition condition = new LongCondition("!=", new Double(10), false);
|
42
|
+
assertTrue(condition.compare(null));
|
43
|
+
assertFalse(condition.compare(new Long(10)));
|
44
|
+
assertTrue(condition.compare(new Long(11)));
|
45
|
+
}
|
46
|
+
|
47
|
+
@Test
|
48
|
+
public void testGreaterThan()
|
49
|
+
{
|
50
|
+
LongCondition condition = new LongCondition(">", new Double(10), false);
|
51
|
+
assertFalse(condition.compare(null));
|
52
|
+
assertFalse(condition.compare(new Long(10)));
|
53
|
+
assertTrue(condition.compare(new Long(11)));
|
54
|
+
}
|
55
|
+
|
56
|
+
@Test
|
57
|
+
public void testGreaterEqual()
|
58
|
+
{
|
59
|
+
LongCondition condition = new LongCondition(">=", new Double(11), false);
|
60
|
+
assertFalse(condition.compare(null));
|
61
|
+
assertFalse(condition.compare(new Long(10)));
|
62
|
+
assertTrue(condition.compare(new Long(11)));
|
63
|
+
}
|
64
|
+
|
65
|
+
@Test
|
66
|
+
public void testLessThan()
|
67
|
+
{
|
68
|
+
LongCondition condition = new LongCondition("<", new Double(11), false);
|
69
|
+
assertFalse(condition.compare(null));
|
70
|
+
assertFalse(condition.compare(new Long(11)));
|
71
|
+
assertTrue(condition.compare(new Long(10)));
|
72
|
+
}
|
73
|
+
|
74
|
+
@Test
|
75
|
+
public void testLessEqual()
|
76
|
+
{
|
77
|
+
LongCondition condition = new LongCondition("<=", new Double(11), false);
|
78
|
+
assertFalse(condition.compare(null));
|
79
|
+
assertFalse(condition.compare(new Long(12)));
|
80
|
+
assertTrue(condition.compare(new Long(11)));
|
81
|
+
}
|
82
|
+
|
83
|
+
@Test
|
84
|
+
public void testNot()
|
85
|
+
{
|
86
|
+
LongCondition condition = new LongCondition("<=", new Double(11), true);
|
87
|
+
assertTrue(condition.compare(null));
|
88
|
+
assertTrue(condition.compare(new Long(12)));
|
89
|
+
assertFalse(condition.compare(new Long(11)));
|
90
|
+
}
|
91
|
+
|
92
|
+
@Test
|
93
|
+
public void testDoubleOperatorEquals()
|
94
|
+
{
|
95
|
+
LongCondition condition = new LongCondition("==", new Double(10.5), false);
|
96
|
+
assertFalse(condition.compare(null));
|
38
97
|
assertFalse(condition.compare(new Long(10)));
|
39
|
-
|
98
|
+
assertFalse(condition.compare(new Long(11)));
|
99
|
+
}
|
100
|
+
|
101
|
+
@Test
|
102
|
+
public void testDoubleOperatorNotEquals()
|
103
|
+
{
|
104
|
+
LongCondition condition = new LongCondition("!=", new Double(10.5), false);
|
105
|
+
assertTrue(condition.compare(null));
|
106
|
+
assertTrue(condition.compare(new Long(10)));
|
107
|
+
assertTrue(condition.compare(new Long(11)));
|
40
108
|
}
|
41
109
|
|
42
110
|
@Test
|
43
|
-
public void
|
44
|
-
|
111
|
+
public void testDoubleOperatorGreaterThan()
|
112
|
+
{
|
113
|
+
LongCondition condition = new LongCondition(">", new Double(10.5), false);
|
45
114
|
assertFalse(condition.compare(null));
|
46
115
|
assertFalse(condition.compare(new Long(10)));
|
47
|
-
assertTrue(
|
116
|
+
assertTrue(condition.compare(new Long(11)));
|
48
117
|
}
|
49
118
|
|
50
119
|
@Test
|
51
|
-
public void
|
52
|
-
|
120
|
+
public void testDoubleOperatorGreaterEqual()
|
121
|
+
{
|
122
|
+
LongCondition condition = new LongCondition(">=", new Double(10.5), false);
|
53
123
|
assertFalse(condition.compare(null));
|
54
124
|
assertFalse(condition.compare(new Long(10)));
|
55
|
-
assertTrue(
|
125
|
+
assertTrue(condition.compare(new Long(11)));
|
56
126
|
}
|
57
127
|
|
58
128
|
@Test
|
59
|
-
public void
|
60
|
-
|
129
|
+
public void testDoubleOperatorLessThan()
|
130
|
+
{
|
131
|
+
LongCondition condition = new LongCondition("<", new Double(10.5), false);
|
61
132
|
assertFalse(condition.compare(null));
|
62
133
|
assertFalse(condition.compare(new Long(11)));
|
63
|
-
assertTrue(
|
134
|
+
assertTrue(condition.compare(new Long(10)));
|
64
135
|
}
|
65
136
|
|
66
137
|
@Test
|
67
|
-
public void
|
68
|
-
|
138
|
+
public void testDoubleOperatorLessEqual()
|
139
|
+
{
|
140
|
+
LongCondition condition = new LongCondition("<=", new Double(11.5), false);
|
69
141
|
assertFalse(condition.compare(null));
|
70
142
|
assertFalse(condition.compare(new Long(12)));
|
71
|
-
assertTrue(
|
143
|
+
assertTrue(condition.compare(new Long(11)));
|
72
144
|
}
|
73
145
|
|
74
146
|
@Test
|
75
|
-
public void
|
76
|
-
|
77
|
-
|
78
|
-
assertTrue(
|
147
|
+
public void testDoubleOperatorNot()
|
148
|
+
{
|
149
|
+
LongCondition condition = new LongCondition("<=", new Double(11.5), true);
|
150
|
+
assertTrue(condition.compare(null));
|
151
|
+
assertTrue(condition.compare(new Long(12)));
|
79
152
|
assertFalse(condition.compare(new Long(11)));
|
80
153
|
}
|
81
154
|
}
|
@@ -1,30 +1,34 @@
|
|
1
1
|
package org.embulk.filter.row;
|
2
2
|
|
3
|
-
import org.embulk.filter.row.StringCondition;
|
4
3
|
import org.junit.Test;
|
5
|
-
|
4
|
+
|
5
|
+
import static org.junit.Assert.assertFalse;
|
6
|
+
import static org.junit.Assert.assertTrue;
|
6
7
|
|
7
8
|
public class TestStringCondition
|
8
9
|
{
|
9
10
|
@Test
|
10
|
-
public void testIsNull()
|
11
|
+
public void testIsNull()
|
12
|
+
{
|
11
13
|
StringCondition condition = new StringCondition("IS NULL", null, false);
|
12
14
|
assertTrue(condition.compare(null));
|
13
15
|
assertFalse(condition.compare("foo"));
|
14
16
|
}
|
15
17
|
|
16
18
|
@Test
|
17
|
-
public void testIsNotNull()
|
19
|
+
public void testIsNotNull()
|
20
|
+
{
|
18
21
|
StringCondition condition = new StringCondition("IS NOT NULL", null, false);
|
19
22
|
assertFalse(condition.compare(null));
|
20
23
|
assertTrue(condition.compare("foo"));
|
21
24
|
}
|
22
25
|
|
23
26
|
@Test
|
24
|
-
public void testEquals()
|
27
|
+
public void testEquals()
|
28
|
+
{
|
25
29
|
StringCondition condition = new StringCondition("==", "foo", false);
|
26
30
|
assertFalse(condition.compare(null));
|
27
|
-
assertTrue(
|
31
|
+
assertTrue(condition.compare("foo"));
|
28
32
|
assertFalse(condition.compare("bar"));
|
29
33
|
|
30
34
|
// Prohibited by Factory
|
@@ -32,66 +36,74 @@ public class TestStringCondition
|
|
32
36
|
}
|
33
37
|
|
34
38
|
@Test
|
35
|
-
public void testNotEquals()
|
39
|
+
public void testNotEquals()
|
40
|
+
{
|
36
41
|
StringCondition condition = new StringCondition("!=", "foo", false);
|
37
|
-
assertTrue(
|
42
|
+
assertTrue(condition.compare(null));
|
38
43
|
assertFalse(condition.compare("foo"));
|
39
|
-
assertTrue(
|
44
|
+
assertTrue(condition.compare("bar"));
|
40
45
|
}
|
41
46
|
|
42
47
|
@Test
|
43
|
-
public void testStartWith()
|
48
|
+
public void testStartWith()
|
49
|
+
{
|
44
50
|
StringCondition condition = new StringCondition("start_with", "f", false);
|
45
51
|
assertFalse(condition.compare(null));
|
46
|
-
assertTrue(
|
52
|
+
assertTrue(condition.compare("foo"));
|
47
53
|
assertFalse(condition.compare("bar"));
|
48
54
|
}
|
49
55
|
|
50
56
|
@Test
|
51
|
-
public void testStartsWith()
|
57
|
+
public void testStartsWith()
|
58
|
+
{
|
52
59
|
StringCondition condition = new StringCondition("startsWith", "f", false);
|
53
60
|
assertFalse(condition.compare(null));
|
54
|
-
assertTrue(
|
61
|
+
assertTrue(condition.compare("foo"));
|
55
62
|
assertFalse(condition.compare("bar"));
|
56
63
|
}
|
57
64
|
|
58
65
|
@Test
|
59
|
-
public void testEndWith()
|
66
|
+
public void testEndWith()
|
67
|
+
{
|
60
68
|
StringCondition condition = new StringCondition("end_with", "o", false);
|
61
69
|
assertFalse(condition.compare(null));
|
62
|
-
assertTrue(
|
70
|
+
assertTrue(condition.compare("foo"));
|
63
71
|
assertFalse(condition.compare("bar"));
|
64
72
|
}
|
65
73
|
|
66
74
|
@Test
|
67
|
-
public void testEndsWith()
|
75
|
+
public void testEndsWith()
|
76
|
+
{
|
68
77
|
StringCondition condition = new StringCondition("endsWith", "o", false);
|
69
78
|
assertFalse(condition.compare(null));
|
70
|
-
assertTrue(
|
79
|
+
assertTrue(condition.compare("foo"));
|
71
80
|
assertFalse(condition.compare("bar"));
|
72
81
|
}
|
73
82
|
|
74
83
|
@Test
|
75
|
-
public void testInclude()
|
84
|
+
public void testInclude()
|
85
|
+
{
|
76
86
|
StringCondition condition = new StringCondition("include", "o", false);
|
77
87
|
assertFalse(condition.compare(null));
|
78
|
-
assertTrue(
|
88
|
+
assertTrue(condition.compare("foo"));
|
79
89
|
assertFalse(condition.compare("bar"));
|
80
90
|
}
|
81
91
|
|
82
92
|
@Test
|
83
|
-
public void testContains()
|
93
|
+
public void testContains()
|
94
|
+
{
|
84
95
|
StringCondition condition = new StringCondition("contains", "o", false);
|
85
96
|
assertFalse(condition.compare(null));
|
86
|
-
assertTrue(
|
97
|
+
assertTrue(condition.compare("foo"));
|
87
98
|
assertFalse(condition.compare("bar"));
|
88
99
|
}
|
89
100
|
|
90
101
|
@Test
|
91
|
-
public void testNot()
|
102
|
+
public void testNot()
|
103
|
+
{
|
92
104
|
StringCondition condition = new StringCondition("include", "o", true);
|
93
|
-
assertTrue(
|
105
|
+
assertTrue(condition.compare(null));
|
94
106
|
assertFalse(condition.compare("foo"));
|
95
|
-
assertTrue(
|
107
|
+
assertTrue(condition.compare("bar"));
|
96
108
|
}
|
97
109
|
}
|
@@ -1,32 +1,36 @@
|
|
1
1
|
package org.embulk.filter.row;
|
2
2
|
|
3
|
-
import org.embulk.
|
3
|
+
import org.embulk.spi.time.Timestamp;
|
4
|
+
|
4
5
|
import org.junit.Test;
|
5
|
-
import static org.junit.Assert.*;
|
6
6
|
|
7
|
-
import org.
|
7
|
+
import static org.junit.Assert.assertFalse;
|
8
|
+
import static org.junit.Assert.assertTrue;
|
8
9
|
|
9
10
|
public class TestTimestampCondition
|
10
11
|
{
|
11
12
|
@Test
|
12
|
-
public void testIsNull()
|
13
|
+
public void testIsNull()
|
14
|
+
{
|
13
15
|
TimestampCondition condition = new TimestampCondition("IS NULL", null, false);
|
14
16
|
assertTrue(condition.compare(null));
|
15
17
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(10)));
|
16
18
|
}
|
17
19
|
|
18
20
|
@Test
|
19
|
-
public void testIsNotNull()
|
21
|
+
public void testIsNotNull()
|
22
|
+
{
|
20
23
|
TimestampCondition condition = new TimestampCondition("IS NOT NULL", null, false);
|
21
24
|
assertFalse(condition.compare(null));
|
22
25
|
assertTrue(condition.compare(Timestamp.ofEpochSecond(10)));
|
23
26
|
}
|
24
27
|
|
25
28
|
@Test
|
26
|
-
public void testEquals()
|
29
|
+
public void testEquals()
|
30
|
+
{
|
27
31
|
TimestampCondition condition = new TimestampCondition("==", Timestamp.ofEpochSecond(10), false);
|
28
32
|
assertFalse(condition.compare(null));
|
29
|
-
assertTrue(
|
33
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(10)));
|
30
34
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(11)));
|
31
35
|
|
32
36
|
// Prohibited by Factory
|
@@ -34,50 +38,56 @@ public class TestTimestampCondition
|
|
34
38
|
}
|
35
39
|
|
36
40
|
@Test
|
37
|
-
public void testNotEquals()
|
41
|
+
public void testNotEquals()
|
42
|
+
{
|
38
43
|
TimestampCondition condition = new TimestampCondition("!=", Timestamp.ofEpochSecond(10), false);
|
39
|
-
assertTrue(
|
44
|
+
assertTrue(condition.compare(null));
|
40
45
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(10)));
|
41
|
-
assertTrue(
|
46
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(11)));
|
42
47
|
}
|
43
48
|
|
44
49
|
@Test
|
45
|
-
public void testGreaterThan()
|
50
|
+
public void testGreaterThan()
|
51
|
+
{
|
46
52
|
TimestampCondition condition = new TimestampCondition(">", Timestamp.ofEpochSecond(10), false);
|
47
53
|
assertFalse(condition.compare(null));
|
48
54
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(10)));
|
49
|
-
assertTrue(
|
55
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(11)));
|
50
56
|
}
|
51
57
|
|
52
58
|
@Test
|
53
|
-
public void testGreaterEqual()
|
59
|
+
public void testGreaterEqual()
|
60
|
+
{
|
54
61
|
TimestampCondition condition = new TimestampCondition(">=", Timestamp.ofEpochSecond(11), false);
|
55
62
|
assertFalse(condition.compare(null));
|
56
63
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(10)));
|
57
|
-
assertTrue(
|
64
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(11)));
|
58
65
|
}
|
59
66
|
|
60
67
|
@Test
|
61
|
-
public void testLessThan()
|
68
|
+
public void testLessThan()
|
69
|
+
{
|
62
70
|
TimestampCondition condition = new TimestampCondition("<", Timestamp.ofEpochSecond(11), false);
|
63
71
|
assertFalse(condition.compare(null));
|
64
72
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(11)));
|
65
|
-
assertTrue(
|
73
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(10)));
|
66
74
|
}
|
67
75
|
|
68
76
|
@Test
|
69
|
-
public void testLessEqual()
|
77
|
+
public void testLessEqual()
|
78
|
+
{
|
70
79
|
TimestampCondition condition = new TimestampCondition("<=", Timestamp.ofEpochSecond(11), false);
|
71
80
|
assertFalse(condition.compare(null));
|
72
81
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(12)));
|
73
|
-
assertTrue(
|
82
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(11)));
|
74
83
|
}
|
75
84
|
|
76
85
|
@Test
|
77
|
-
public void testNot()
|
86
|
+
public void testNot()
|
87
|
+
{
|
78
88
|
TimestampCondition condition = new TimestampCondition("<=", Timestamp.ofEpochSecond(11), true);
|
79
|
-
assertTrue(
|
80
|
-
assertTrue(
|
89
|
+
assertTrue(condition.compare(null));
|
90
|
+
assertTrue(condition.compare(Timestamp.ofEpochSecond(12)));
|
81
91
|
assertFalse(condition.compare(Timestamp.ofEpochSecond(11)));
|
82
92
|
}
|
83
93
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-filter-row
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,13 +51,16 @@ files:
|
|
51
51
|
- LICENSE.txt
|
52
52
|
- README.md
|
53
53
|
- build.gradle
|
54
|
+
- config/checkstyle/checkstyle.xml
|
54
55
|
- example/and.yml
|
56
|
+
- example/example.csv
|
55
57
|
- example/or.yml
|
56
58
|
- gradle/wrapper/gradle-wrapper.jar
|
57
59
|
- gradle/wrapper/gradle-wrapper.properties
|
58
60
|
- gradlew
|
59
61
|
- gradlew.bat
|
60
62
|
- lib/embulk/filter/row.rb
|
63
|
+
- settings.gradle
|
61
64
|
- src/main/java/org/embulk/filter/RowFilterPlugin.java
|
62
65
|
- src/main/java/org/embulk/filter/row/BooleanCondition.java
|
63
66
|
- src/main/java/org/embulk/filter/row/Condition.java
|
@@ -74,7 +77,7 @@ files:
|
|
74
77
|
- src/test/java/org/embulk/filter/row/TestLongCondition.java
|
75
78
|
- src/test/java/org/embulk/filter/row/TestStringCondition.java
|
76
79
|
- src/test/java/org/embulk/filter/row/TestTimestampCondition.java
|
77
|
-
- classpath/embulk-filter-row-0.2.
|
80
|
+
- classpath/embulk-filter-row-0.2.1.jar
|
78
81
|
homepage: https://github.com/sonots/embulk-filter-row
|
79
82
|
licenses:
|
80
83
|
- MIT
|
Binary file
|