embulk-output-redshift 0.7.11 → 0.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d64af8464bfac5a262069e316fa1227072de6322
4
- data.tar.gz: 4b17ad7085953c573fcc56186c5ab1ca93cec8ca
3
+ metadata.gz: 0f49d2ce2f0a28ab1a34ad8e0a1a5b3df3dac5e8
4
+ data.tar.gz: da8446b33c11ac4f1736d37ad60c9e3dd9faf2f8
5
5
  SHA512:
6
- metadata.gz: c8d003c33121591debba7c54e942026caa25dfe9f2cf64622f1dd66cfbf8828b8639b149391497bb99659125050dbef00d4ff508beb32d91d401861a239dacc9
7
- data.tar.gz: 765d334d8521f215d1165b82800bdd5ad3b25f3471fa86f22b4d0676670ada1ab72be25f4bafb87ab97903aa27a7d7173da0cf71830342709703eb88db9073c1
6
+ metadata.gz: f6f4a3167321def1c531d9e94f1988441309a9127949f508b660eae5a6dad5763e52c434681bf670f06026bf6aed8babfccb10f3193115468d06f639cb203d91
7
+ data.tar.gz: 8f7681e29c631b46570f87d43920f64f3b6e5c8440becdaf48aa5d71440acd9031a8cb227b78ab442fe1c18c33cea061fe580d8f15fd386874a930e150193b4e
data/README.md CHANGED
@@ -98,7 +98,7 @@ Redshift output plugin for Embulk loads records to Redshift.
98
98
  * Transactional: Yes.
99
99
  * Resumable: No.
100
100
  * **merge**:
101
- * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, inserts new records from intermediate tables after updating records whose keys exist in intermediate tables. Namely, if merge keys of a record in the intermediate tables already exist in the target table, the target record is updated by the intermediate record, otherwise the intermediate record is inserted. If the target table doesn't exist, it is created automatically.
101
+ * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, inserts new records from intermediate tables after updating records whose keys exist in intermediate tables. Namely, if merge keys of a record in the intermediate tables already exist in the target table, the target record is updated by the intermediate record, otherwise the intermediate record is inserted. If the target table doesn't exist, it is created automatically. NOTE: Merge does not work correctly if merge keys contain `NULL`s.
102
102
  * Transactional: Yes.
103
103
  * Resumable: Yes.
104
104
 
@@ -28,66 +28,21 @@ public class RedshiftOutputConnection
28
28
  connection.setAutoCommit(autoCommit);
29
29
  }
30
30
 
31
- // Redshift does not support DROP TABLE IF EXISTS.
32
- // Here runs DROP TABLE and ignores errors.
31
+ // ALTER TABLE cannot change the schema of a table
32
+ //
33
+ // Standard JDBC:
34
+ // ALTER TABLE "public"."source" RENAME TO "public"."target"
35
+ // Redshift:
36
+ // ALTER TABLE "public"."source" RENAME TO "target"
33
37
  @Override
34
- public void dropTableIfExists(TableIdentifier table) throws SQLException
38
+ protected String buildRenameTableSql(TableIdentifier fromTable, TableIdentifier toTable)
35
39
  {
36
- Statement stmt = connection.createStatement();
37
- try {
38
- String sql = String.format("DROP TABLE IF EXISTS %s", quoteTableIdentifier(table));
39
- executeUpdate(stmt, sql);
40
- commitIfNecessary(connection);
41
- } catch (SQLException ex) {
42
- // ignore errors.
43
- // TODO here should ignore only 'table "XXX" does not exist' errors.
44
- SQLException ignored = safeRollback(connection, ex);
45
- } finally {
46
- stmt.close();
47
- }
48
- }
49
-
50
- // Redshift does not support DROP TABLE IF EXISTS.
51
- // Dropping part runs DROP TABLE and ignores errors.
52
- @Override
53
- public void replaceTable(TableIdentifier fromTable, JdbcSchema schema, TableIdentifier toTable, Optional<String> additionalSql) throws SQLException
54
- {
55
- Statement stmt = connection.createStatement();
56
- try {
57
- try {
58
- StringBuilder sb = new StringBuilder();
59
- sb.append("DROP TABLE ");
60
- quoteTableIdentifier(sb, toTable);
61
- String sql = sb.toString();
62
- executeUpdate(stmt, sql);
63
- } catch (SQLException ex) {
64
- // ignore errors.
65
- // TODO here should ignore only 'table "XXX" does not exist' errors.
66
- // rollback or comimt is required to recover failed transaction
67
- SQLException ignored = safeRollback(connection, ex);
68
- }
69
-
70
- {
71
- // ALTER TABLE cannot change schema of table
72
- StringBuilder sb = new StringBuilder();
73
- sb.append("ALTER TABLE ");
74
- quoteTableIdentifier(sb, fromTable);
75
- sb.append(" RENAME TO ");
76
- quoteIdentifierString(sb, toTable.getTableName());
77
- String sql = sb.toString();
78
- executeUpdate(stmt, sql);
79
- }
80
-
81
- if (additionalSql.isPresent()) {
82
- executeUpdate(stmt, additionalSql.get());
83
- }
84
-
85
- commitIfNecessary(connection);
86
- } catch (SQLException ex) {
87
- throw safeRollback(connection, ex);
88
- } finally {
89
- stmt.close();
90
- }
40
+ StringBuilder sb = new StringBuilder();
41
+ sb.append("ALTER TABLE ");
42
+ quoteTableIdentifier(sb, fromTable);
43
+ sb.append(" RENAME TO ");
44
+ quoteIdentifierString(sb, toTable.getTableName());
45
+ return sb.toString();
91
46
  }
92
47
 
93
48
  @Override
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-redshift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.11
4
+ version: 0.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Inserts or updates records to a table.
14
14
  email:
@@ -25,9 +25,9 @@ files:
25
25
  - classpath/aws-java-sdk-sts-1.10.77.jar
26
26
  - classpath/commons-codec-1.6.jar
27
27
  - classpath/commons-logging-1.1.3.jar
28
- - classpath/embulk-output-jdbc-0.7.11.jar
29
- - classpath/embulk-output-postgresql-0.7.11.jar
30
- - classpath/embulk-output-redshift-0.7.11.jar
28
+ - classpath/embulk-output-jdbc-0.7.12.jar
29
+ - classpath/embulk-output-postgresql-0.7.12.jar
30
+ - classpath/embulk-output-redshift-0.7.12.jar
31
31
  - classpath/embulk-util-aws-credentials-0.2.8.jar
32
32
  - classpath/httpclient-4.3.6.jar
33
33
  - classpath/httpcore-4.3.3.jar