src/main/java/org/embulk/output/PostgreSQLOutputPlugin.java in embulk-output-postgresql-0.7.8 vs src/main/java/org/embulk/output/PostgreSQLOutputPlugin.java in embulk-output-postgresql-0.7.9
- old
+ new
@@ -46,10 +46,14 @@
@Config("schema")
@ConfigDefault("\"public\"")
public String getSchema();
+ @Config("temp_schema")
+ @ConfigDefault("null")
+ public Optional<String> getTempSchema();
+
@Config("ssl")
@ConfigDefault("false")
public boolean getSsl();
}
@@ -103,9 +107,19 @@
props.setProperty("user", t.getUser());
logger.info("Connecting to {} options {}", url, props);
props.setProperty("password", t.getPassword());
return new PostgreSQLOutputConnector(url, props, t.getSchema());
+ }
+
+ @Override
+ protected TableIdentifier buildIntermediateTableId(JdbcOutputConnection con, PluginTask task, String tableName) {
+ PostgreSQLPluginTask t = (PostgreSQLPluginTask) task;
+ // replace mode doesn't support temp_schema because ALTER TABLE cannot change schema of table
+ if (t.getTempSchema().isPresent() && t.getMode() != Mode.REPLACE) {
+ return new TableIdentifier(null, t.getTempSchema().get(), tableName);
+ }
+ return super.buildIntermediateTableId(con, task, tableName);
}
@Override
protected BatchInsert newBatchInsert(PluginTask task, Optional<MergeConfig> mergeConfig) throws IOException, SQLException
{