Skip to content

Commit d0fad24

Browse files
committed
add delete_stage_on_error option
1 parent 6c9633b commit d0fad24

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/org/embulk/output/SnowflakeOutputPlugin.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public interface SnowflakePluginTask extends PluginTask {
6666
@Config("empty_field_as_null")
6767
@ConfigDefault("true")
6868
public boolean getEmtpyFieldAsNull();
69+
70+
@Config("delete_stage_on_error")
71+
@ConfigDefault("false")
72+
public boolean getDeleteStageOnError();
6973
}
7074

7175
@Override
@@ -143,16 +147,16 @@ public ConfigDiff transaction(
143147
snowflakeCon = (SnowflakeOutputConnection) getConnector(task, true).connect(true);
144148
snowflakeCon.runCreateStage(this.stageIdentifier);
145149
configDiff = super.transaction(config, schema, taskCount, control);
146-
} catch (SQLException ex) {
147-
throw new RuntimeException(ex);
148-
} finally {
149-
if (t.getDeleteStage()) {
150+
snowflakeCon.runDropStage(this.stageIdentifier);
151+
} catch (Exception e) {
152+
if (t.getDeleteStageOnError()) {
150153
try {
151154
snowflakeCon.runDropStage(this.stageIdentifier);
152155
} catch (SQLException ex) {
153156
throw new RuntimeException(ex);
154157
}
155158
}
159+
throw new RuntimeException(e);
156160
}
157161

158162
return configDiff;

0 commit comments

Comments
 (0)