Skip to content

Commit

Permalink
Merge pull request #70 from treasure-data/dynamic_schema_graceful_exit
Browse files Browse the repository at this point in the history
Graceful shutdown in case no records for dynamic schema
  • Loading branch information
minidragon88 committed Oct 4, 2021
2 parents 17ec514 + 0d382ea commit 5ec0ccc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## 0.2.14 - 2021-10-12
* [enhancement] Graceful exit in case no data of dynamic schema
* PR [#70](https://github.com/treasure-data/embulk-input-jira/pull/70)

## 0.2.13 - 2021-09-30
* [enhancement] Support dynamic schema
* PR [#69](https://github.com/treasure-data/embulk-input-jira/pull/69)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -12,7 +12,7 @@ repositories {
jcenter()
}

version = "0.2.13"
version = "0.2.14"
group = "com.treasuredata.embulk.plugins"
description = "JIRA Embulk input plugin."

Expand Down
13 changes: 10 additions & 3 deletions src/main/java/org/embulk/input/jira/JiraInputPlugin.java
Expand Up @@ -109,9 +109,16 @@ public ConfigDiff transaction(final ConfigSource config,
if (task.getDynamicSchema()) {
final JiraClient jiraClient = getJiraClient();
final List<ColumnConfig> columns = new ArrayList<>();
final List<ConfigDiff> guessedColumns = getGuessedColumns(jiraClient, task);
for (final ConfigDiff guessedColumn : guessedColumns) {
columns.add(new ColumnConfig(CONFIG_MAPPER_FACTORY.newConfigSource().merge(guessedColumn)));
try {
final List<ConfigDiff> guessedColumns = getGuessedColumns(jiraClient, task);
for (final ConfigDiff guessedColumn : guessedColumns) {
columns.add(new ColumnConfig(CONFIG_MAPPER_FACTORY.newConfigSource().merge(guessedColumn)));
}
}
catch (final ConfigException e) {
if (!e.getMessage().equals("Could not guess schema due to empty data set")) {
throw e;
}
}
schemaConfig = new SchemaConfig(columns);
}
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/org/embulk/input/jira/JiraInputPluginTest.java
Expand Up @@ -10,7 +10,6 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.embulk.EmbulkTestRuntime;
import org.embulk.config.ConfigDiff;
import org.embulk.config.ConfigException;
import org.embulk.config.ConfigSource;
import org.embulk.config.TaskReport;
import org.embulk.config.TaskSource;
Expand Down Expand Up @@ -90,7 +89,6 @@ public void test_run_withEmptyResult() throws IOException
verify(pageBuilder, times(1)).finish();
}

@Test(expected = ConfigException.class)
public void test_runDynamicSchema_withEmptyResult() throws IOException
{
final JsonObject searchResponse = data.get("emptyResult").getAsJsonObject();
Expand All @@ -99,8 +97,8 @@ public void test_runDynamicSchema_withEmptyResult() throws IOException
.thenReturn(searchResponse.get("statusCode").getAsInt());
when(response.getEntity())
.thenReturn(new StringEntity(searchResponse.get("body").toString()));

plugin.transaction(TestHelpers.dynamicSchemaConfig(), new Control());
verify(pageBuilder, times(0)).addRecord();
}

@Test
Expand Down

0 comments on commit 5ec0ccc

Please sign in to comment.