embulk 0.8.15 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/appveyor.yml +8 -0
- data/build.gradle +86 -45
- data/embulk-core/src/main/java/org/embulk/config/TaskValidationException.java +1 -1
- data/embulk-core/src/main/java/org/embulk/exec/SamplingParserPlugin.java +43 -4
- data/embulk-core/src/main/java/org/embulk/spi/PageBuilder.java +15 -0
- data/embulk-core/src/main/java/org/embulk/spi/util/ResumableInputStream.java +38 -1
- data/embulk-docs/src/built-in.rst +34 -0
- data/embulk-docs/src/release.rst +1 -0
- data/embulk-docs/src/release/release-0.8.16.rst +43 -0
- data/embulk-standards/build.gradle +1 -0
- data/embulk-standards/src/main/java/org/embulk/standards/RemoveColumnsFilterPlugin.java +268 -0
- data/embulk-standards/src/main/java/org/embulk/standards/RenameFilterPlugin.java +13 -0
- data/embulk-standards/src/main/java/org/embulk/standards/StandardPluginModule.java +1 -0
- data/embulk-standards/src/test/java/org/embulk/standards/TestRemoveColumnsFilterPlugin.java +121 -0
- data/embulk-standards/src/test/java/org/embulk/standards/TestRenameFilterPlugin.java +8 -0
- data/embulk-standards/src/test/java/org/embulk/standards/guess/TestCsvAllStringsGuessPlugin.java +38 -0
- data/embulk-standards/src/test/java/org/embulk/standards/guess/TestCsvGuessPlugin.java +229 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row.csv +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row_and_header.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row_and_header_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row_and_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_int_single_column_row_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows.csv +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header_with_trim_needed.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header_with_trim_needed_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_and_header_with_trim_needed_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_with_trim_needed.csv +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_with_trim_needed_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_with_trim_needed_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row.csv +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row_and_header.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row_and_header_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row_and_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_string_single_column_row_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_int_single_column_rows.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_int_single_column_rows_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_int_single_column_rows_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows_and_header.csv +3 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows_and_header_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows_and_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_rows_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_string_single_column_rows.csv +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_string_single_column_rows_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_2_string_single_column_rows_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_backslash_escape.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_backslash_escape_guessed.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_backslash_escape_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column_with_header.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column_with_header_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_int_single_column_with_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_semicolon_delimiter.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_semicolon_delimiter_guessed.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_semicolon_delimiter_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_simple.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_simple_guessed.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_simple_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_single_quote.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_single_quote_guessed.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_single_quote_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column_with_header.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column_with_header_guessed.yml +12 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_string_single_column_with_header_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_tab_delimiter.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_tab_delimiter_guessed.yml +16 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_tab_delimiter_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv_all_strings/test/test_simple.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv_all_strings/test/test_simple_guessed.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv_all_strings/test/test_simple_seed.yml +1 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_expected.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_filter.yml +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_in.yml +18 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_with_duplicated_column_names.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_with_duplicated_column_names.yml +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_with_duplicated_column_names_expected.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_with_duplicated_column_names_in.yml +17 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_with_unmatched_filter.yml +3 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_keep_without_unmatched_filter.yml +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove.csv +5 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove_expected.csv +4 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove_filter.yml +2 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove_in.yml +18 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove_with_unmatched_filter.yml +3 -0
- data/embulk-standards/src/test/resources/org/embulk/standards/remove_columns/test/test_remove_without_unmatched_filter.yml +2 -0
- data/embulk-test/src/main/java/org/embulk/test/TestingEmbulk.java +458 -28
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/gradlew +30 -21
- data/gradlew.bat +4 -10
- data/lib/embulk/command/embulk_migrate_plugin.rb +2 -2
- data/lib/embulk/data/new/java/build.gradle.erb +5 -3
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/embulk/data/new/java/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/lib/embulk/data/new/java/gradlew +30 -21
- data/lib/embulk/data/new/java/gradlew.bat +4 -10
- data/lib/embulk/guess/csv.rb +44 -22
- data/lib/embulk/guess/newline.rb +10 -4
- data/lib/embulk/guess_plugin.rb +3 -1
- data/lib/embulk/java/time_helper.rb +2 -2
- data/lib/embulk/version.rb +1 -1
- metadata +92 -5
@@ -31,6 +31,14 @@ import static org.junit.Assert.assertEquals;
|
|
31
31
|
import static org.junit.Assert.assertTrue;
|
32
32
|
import static org.junit.Assert.fail;
|
33
33
|
|
34
|
+
/**
|
35
|
+
* Testing |RenameFilterPlugin|.
|
36
|
+
*
|
37
|
+
* NOTE: DO NOT CHANGE THE EXISTING TESTS.
|
38
|
+
*
|
39
|
+
* As written in the comment of |RenameFilterPlugin|, the existing behaviors
|
40
|
+
* should not change so that users are not confused.
|
41
|
+
*/
|
34
42
|
public class TestRenameFilterPlugin
|
35
43
|
{
|
36
44
|
@Rule
|
data/embulk-standards/src/test/java/org/embulk/standards/guess/TestCsvAllStringsGuessPlugin.java
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
package org.embulk.standards.guess;
|
2
|
+
|
3
|
+
import com.google.common.collect.ImmutableList;
|
4
|
+
import org.embulk.config.ConfigDiff;
|
5
|
+
import org.embulk.config.ConfigSource;
|
6
|
+
import org.embulk.config.DataSource;
|
7
|
+
import org.embulk.test.TestingEmbulk;
|
8
|
+
import org.junit.Rule;
|
9
|
+
import org.junit.Test;
|
10
|
+
|
11
|
+
import static org.hamcrest.Matchers.is;
|
12
|
+
import static org.junit.Assert.assertThat;
|
13
|
+
|
14
|
+
public class TestCsvAllStringsGuessPlugin
|
15
|
+
{
|
16
|
+
private static final String RESOURCE_NAME_PREFIX = "org/embulk/standards/guess/csv_all_strings/test/";
|
17
|
+
|
18
|
+
@Rule
|
19
|
+
public TestingEmbulk embulk = TestingEmbulk.builder()
|
20
|
+
.build();
|
21
|
+
|
22
|
+
@Test
|
23
|
+
public void testSimple()
|
24
|
+
throws Exception
|
25
|
+
{
|
26
|
+
ConfigSource exec = embulk.newConfig()
|
27
|
+
.set("guess_plugins", ImmutableList.of("csv_all_strings"))
|
28
|
+
.set("exclude_guess_plugins", ImmutableList.of("csv"));
|
29
|
+
|
30
|
+
ConfigDiff guessed =
|
31
|
+
embulk.parserBuilder()
|
32
|
+
.exec(exec)
|
33
|
+
.inputResource(RESOURCE_NAME_PREFIX + "test_simple.csv")
|
34
|
+
.guess();
|
35
|
+
|
36
|
+
assertThat(guessed, is((DataSource) embulk.loadYamlResource(RESOURCE_NAME_PREFIX + "test_simple_guessed.yml")));
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,229 @@
|
|
1
|
+
package org.embulk.standards.guess;
|
2
|
+
|
3
|
+
import com.google.common.collect.ImmutableList;
|
4
|
+
import org.embulk.config.ConfigDiff;
|
5
|
+
import org.embulk.config.ConfigSource;
|
6
|
+
import org.embulk.config.DataSource;
|
7
|
+
import org.embulk.test.TestingEmbulk;
|
8
|
+
import org.junit.Rule;
|
9
|
+
import org.junit.Test;
|
10
|
+
|
11
|
+
import java.io.IOException;
|
12
|
+
|
13
|
+
import static org.hamcrest.Matchers.is;
|
14
|
+
import static org.junit.Assert.assertThat;
|
15
|
+
|
16
|
+
public class TestCsvGuessPlugin
|
17
|
+
{
|
18
|
+
private static final String RESOURCE_NAME_PREFIX = "org/embulk/standards/guess/csv/test/";
|
19
|
+
|
20
|
+
@Rule
|
21
|
+
public TestingEmbulk embulk = TestingEmbulk.builder()
|
22
|
+
.build();
|
23
|
+
|
24
|
+
@Test
|
25
|
+
public void testSimple()
|
26
|
+
throws Exception
|
27
|
+
{
|
28
|
+
assertGuessByResource(embulk,
|
29
|
+
"test_simple_seed.yml", "test_simple.csv",
|
30
|
+
"test_simple_guessed.yml");
|
31
|
+
}
|
32
|
+
|
33
|
+
@Test
|
34
|
+
public void testFor1Rows()
|
35
|
+
throws Exception
|
36
|
+
{
|
37
|
+
assertGuessByResource(embulk,
|
38
|
+
"test_1_rows_seed.yml", "test_1_rows.csv",
|
39
|
+
"test_1_rows_guessed.yml");
|
40
|
+
}
|
41
|
+
|
42
|
+
@Test
|
43
|
+
public void testFor1RowsWithTrimNeeded()
|
44
|
+
throws Exception
|
45
|
+
{
|
46
|
+
assertGuessByResource(embulk,
|
47
|
+
"test_1_rows_with_trim_needed_seed.yml", "test_1_rows_with_trim_needed.csv",
|
48
|
+
"test_1_rows_with_trim_needed_guessed.yml");
|
49
|
+
}
|
50
|
+
|
51
|
+
@Test
|
52
|
+
public void testFor1RowsAndHeader()
|
53
|
+
throws Exception
|
54
|
+
{
|
55
|
+
assertGuessByResource(embulk,
|
56
|
+
"test_1_rows_and_header_seed.yml", "test_1_rows_and_header.csv",
|
57
|
+
"test_1_rows_and_header_guessed.yml");
|
58
|
+
}
|
59
|
+
|
60
|
+
@Test
|
61
|
+
public void testFor1RowsAndHeaderWithTrimNeeded()
|
62
|
+
throws Exception
|
63
|
+
{
|
64
|
+
assertGuessByResource(embulk,
|
65
|
+
"test_1_rows_and_header_with_trim_needed_seed.yml", "test_1_rows_and_header_with_trim_needed.csv",
|
66
|
+
"test_1_rows_and_header_with_trim_needed_guessed.yml");
|
67
|
+
}
|
68
|
+
|
69
|
+
@Test
|
70
|
+
public void testFor2Rows()
|
71
|
+
throws Exception
|
72
|
+
{
|
73
|
+
assertGuessByResource(embulk,
|
74
|
+
"test_2_rows_seed.yml", "test_2_rows.csv",
|
75
|
+
"test_2_rows_guessed.yml");
|
76
|
+
}
|
77
|
+
|
78
|
+
@Test
|
79
|
+
public void testFor2RowsAndHeader()
|
80
|
+
throws Exception
|
81
|
+
{
|
82
|
+
assertGuessByResource(embulk,
|
83
|
+
"test_2_rows_and_header_seed.yml", "test_2_rows_and_header.csv",
|
84
|
+
"test_2_rows_and_header_guessed.yml");
|
85
|
+
}
|
86
|
+
|
87
|
+
@Test
|
88
|
+
public void testFor1IntSingleColumnRow()
|
89
|
+
throws Exception
|
90
|
+
{
|
91
|
+
assertGuessByResource(embulk,
|
92
|
+
"test_1_int_single_column_row_seed.yml", "test_1_int_single_column_row.csv",
|
93
|
+
"test_1_int_single_column_row_guessed.yml");
|
94
|
+
}
|
95
|
+
|
96
|
+
@Test
|
97
|
+
public void testFor1StringSingleColumnRow()
|
98
|
+
throws Exception
|
99
|
+
{
|
100
|
+
assertGuessByResource(embulk,
|
101
|
+
"test_1_string_single_column_row_seed.yml", "test_1_string_single_column_row.csv",
|
102
|
+
"test_1_string_single_column_row_guessed.yml");
|
103
|
+
}
|
104
|
+
|
105
|
+
@Test
|
106
|
+
public void testFor2StringSingleColumnRows()
|
107
|
+
throws Exception
|
108
|
+
{
|
109
|
+
assertGuessByResource(embulk,
|
110
|
+
"test_2_string_single_column_rows_seed.yml", "test_2_string_single_column_rows.csv",
|
111
|
+
"test_2_string_single_column_rows_guessed.yml");
|
112
|
+
}
|
113
|
+
|
114
|
+
@Test
|
115
|
+
public void testFor1StringSingleColumnAndHeader()
|
116
|
+
throws Exception
|
117
|
+
{
|
118
|
+
assertGuessByResource(embulk,
|
119
|
+
"test_1_string_single_column_row_and_header_seed.yml", "test_1_string_single_column_row_and_header.csv",
|
120
|
+
"test_1_string_single_column_row_and_header_guessed.yml");
|
121
|
+
}
|
122
|
+
|
123
|
+
@Test
|
124
|
+
public void testFor2IntSingleColumnRows()
|
125
|
+
throws Exception
|
126
|
+
{
|
127
|
+
assertGuessByResource(embulk,
|
128
|
+
"test_2_int_single_column_rows_seed.yml", "test_2_int_single_column_rows.csv",
|
129
|
+
"test_2_int_single_column_rows_guessed.yml");
|
130
|
+
}
|
131
|
+
|
132
|
+
@Test
|
133
|
+
public void testFor1IntSingleColumnAndHeader()
|
134
|
+
throws Exception
|
135
|
+
{
|
136
|
+
assertGuessByResource(embulk,
|
137
|
+
"test_1_int_single_column_row_and_header_seed.yml", "test_1_int_single_column_row_and_header.csv",
|
138
|
+
"test_1_int_single_column_row_and_header_guessed.yml");
|
139
|
+
}
|
140
|
+
|
141
|
+
@Test
|
142
|
+
public void testIntSingleColumnWithHeader()
|
143
|
+
throws Exception
|
144
|
+
{
|
145
|
+
assertGuessByResource(embulk,
|
146
|
+
"test_int_single_column_with_header_seed.yml", "test_int_single_column_with_header.csv",
|
147
|
+
"test_int_single_column_with_header_guessed.yml");
|
148
|
+
}
|
149
|
+
|
150
|
+
@Test
|
151
|
+
public void testIntSingleColumn()
|
152
|
+
throws Exception
|
153
|
+
{
|
154
|
+
assertGuessByResource(embulk,
|
155
|
+
"test_int_single_column_seed.yml", "test_int_single_column.csv",
|
156
|
+
"test_int_single_column_guessed.yml");
|
157
|
+
}
|
158
|
+
|
159
|
+
@Test
|
160
|
+
public void testStringSingleColumnWithHeader()
|
161
|
+
throws Exception
|
162
|
+
{
|
163
|
+
assertGuessByResource(embulk,
|
164
|
+
"test_string_single_column_with_header_seed.yml", "test_string_single_column_with_header.csv",
|
165
|
+
"test_string_single_column_with_header_guessed.yml");
|
166
|
+
}
|
167
|
+
|
168
|
+
@Test
|
169
|
+
public void testStringSingleColumn()
|
170
|
+
throws Exception
|
171
|
+
{
|
172
|
+
assertGuessByResource(embulk,
|
173
|
+
"test_string_single_column_seed.yml", "test_string_single_column.csv",
|
174
|
+
"test_string_single_column_guessed.yml");
|
175
|
+
}
|
176
|
+
|
177
|
+
@Test
|
178
|
+
public void suggestTabAsDelimiter()
|
179
|
+
throws Exception
|
180
|
+
{
|
181
|
+
assertGuessByResource(embulk,
|
182
|
+
"test_tab_delimiter_seed.yml", "test_tab_delimiter.csv",
|
183
|
+
"test_tab_delimiter_guessed.yml");
|
184
|
+
}
|
185
|
+
|
186
|
+
@Test
|
187
|
+
public void suggestSemicolonAsDelimiter()
|
188
|
+
throws Exception
|
189
|
+
{
|
190
|
+
assertGuessByResource(embulk,
|
191
|
+
"test_semicolon_delimiter_seed.yml", "test_semicolon_delimiter.csv",
|
192
|
+
"test_semicolon_delimiter_guessed.yml");
|
193
|
+
}
|
194
|
+
|
195
|
+
@Test
|
196
|
+
public void suggestSingleQuoteAsQuote()
|
197
|
+
throws Exception
|
198
|
+
{
|
199
|
+
assertGuessByResource(embulk,
|
200
|
+
"test_single_quote_seed.yml", "test_single_quote.csv",
|
201
|
+
"test_single_quote_guessed.yml");
|
202
|
+
}
|
203
|
+
|
204
|
+
@Test
|
205
|
+
public void suggestBackslashAsEscape()
|
206
|
+
throws Exception
|
207
|
+
{
|
208
|
+
assertGuessByResource(embulk,
|
209
|
+
"test_backslash_escape_seed.yml", "test_backslash_escape.csv",
|
210
|
+
"test_backslash_escape_guessed.yml");
|
211
|
+
}
|
212
|
+
|
213
|
+
static void assertGuessByResource(TestingEmbulk embulk, String seedYamlResourceName, String sourceCsvResourceName,
|
214
|
+
String resultResourceName)
|
215
|
+
throws IOException
|
216
|
+
{
|
217
|
+
ConfigSource seed = embulk.loadYamlResource(RESOURCE_NAME_PREFIX + seedYamlResourceName);
|
218
|
+
|
219
|
+
ConfigDiff guessed =
|
220
|
+
embulk.parserBuilder()
|
221
|
+
.parser(seed)
|
222
|
+
.exec(embulk.newConfig().set("exclude_guess_plugins", ImmutableList.of("json")))
|
223
|
+
.inputResource(RESOURCE_NAME_PREFIX + sourceCsvResourceName)
|
224
|
+
.guess();
|
225
|
+
|
226
|
+
assertThat(guessed, is((DataSource) embulk.loadYamlResource(RESOURCE_NAME_PREFIX + resultResourceName)));
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
1
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1 @@
|
|
1
|
+
1,32864,2015-01-27 19:23:49,20150127,embulk
|
@@ -0,0 +1,16 @@
|
|
1
|
+
charset: UTF-8
|
2
|
+
newline: LF
|
3
|
+
type: csv
|
4
|
+
delimiter: ','
|
5
|
+
quote: '"'
|
6
|
+
escape: '"'
|
7
|
+
trim_if_not_quoted: false
|
8
|
+
skip_header_lines: 1
|
9
|
+
allow_extra_columns: false
|
10
|
+
allow_optional_columns: false
|
11
|
+
columns:
|
12
|
+
- {name: id, type: long}
|
13
|
+
- {name: account, type: long}
|
14
|
+
- {name: time, type: timestamp, format: '%Y-%m-%d %H:%M:%S'}
|
15
|
+
- {name: purchase, type: timestamp, format: '%Y%m%d'}
|
16
|
+
- {name: comment, type: string}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
charset: UTF-8
|
2
|
+
newline: LF
|
3
|
+
type: csv
|
4
|
+
delimiter: ','
|
5
|
+
quote: '"'
|
6
|
+
escape: '"'
|
7
|
+
trim_if_not_quoted: true
|
8
|
+
skip_header_lines: 1
|
9
|
+
allow_extra_columns: false
|
10
|
+
allow_optional_columns: false
|
11
|
+
columns:
|
12
|
+
- {name: id, type: long}
|
13
|
+
- {name: account, type: long}
|
14
|
+
- {name: time, type: timestamp, format: '%Y-%m-%d %H:%M:%S'}
|
15
|
+
- {name: purchase, type: timestamp, format: '%Y%m%d'}
|
16
|
+
- {name: comment, type: string}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_guessed.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
charset: UTF-8
|
2
|
+
newline: LF
|
3
|
+
type: csv
|
4
|
+
delimiter: ','
|
5
|
+
quote: '"'
|
6
|
+
escape: '"'
|
7
|
+
trim_if_not_quoted: false
|
8
|
+
skip_header_lines: 0
|
9
|
+
allow_extra_columns: false
|
10
|
+
allow_optional_columns: false
|
11
|
+
columns:
|
12
|
+
- {name: c0, type: long}
|
13
|
+
- {name: c1, type: long}
|
14
|
+
- {name: c2, type: timestamp, format: '%Y-%m-%d %H:%M:%S'}
|
15
|
+
- {name: c3, type: timestamp, format: '%Y%m%d'}
|
16
|
+
- {name: c4, type: string}
|
data/embulk-standards/src/test/resources/org/embulk/standards/guess/csv/test/test_1_rows_seed.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1 @@
|
|
1
|
+
1 , 32864 ,2015-01-27 19:23:49, 20150127 , embulk
|
@@ -0,0 +1,16 @@
|
|
1
|
+
charset: UTF-8
|
2
|
+
newline: LF
|
3
|
+
type: csv
|
4
|
+
delimiter: ','
|
5
|
+
quote: '"'
|
6
|
+
escape: '"'
|
7
|
+
trim_if_not_quoted: true
|
8
|
+
skip_header_lines: 0
|
9
|
+
allow_extra_columns: false
|
10
|
+
allow_optional_columns: false
|
11
|
+
columns:
|
12
|
+
- {name: c0, type: long}
|
13
|
+
- {name: c1, type: long}
|
14
|
+
- {name: c2, type: timestamp, format: '%Y-%m-%d %H:%M:%S'}
|
15
|
+
- {name: c3, type: timestamp, format: '%Y%m%d'}
|
16
|
+
- {name: c4, type: string}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1 @@
|
|
1
|
+
ac97447f-146c-4d6c-914e-c283bb165804
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|