embulk-output-postgresql 0.4.1 → 0.4.2

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: 250c4ddbe6b7dcd4b48ac024df131182c5ca5c1c
4
- data.tar.gz: ff78eb2ec44bf83d95f85cb0ebb5986ee734b59a
3
+ metadata.gz: e36dbd816c064b46c20cb2a080accbd7339621fe
4
+ data.tar.gz: c47c5e2470842a87f8f926d4d4ca36bba94ae935
5
5
  SHA512:
6
- metadata.gz: 51126373caeb6aae0f6973ee58fd51fabbbea117de3eb9a8325865f4212140c7705bb0a2101142ffdbe5c3e9dd3846c0f2d5a9e16e805c1aa9bf862320d820cf
7
- data.tar.gz: f43c2719c43b3d6f8d7f212aea42629be582786b9cafb19c19122459ffe4aa5caf96d497ac538f0890d404e311749f55100f9a784ee7e6a55ad20db3f6c6fd22
6
+ metadata.gz: 8e461480ceb52888c6b4f971a9617c2b1e8a52fc232db00a3179f7098635c31b16aeb0e17521ce33045d92db81e9fac12de3936fed22f3323714f8474a05c3d0
7
+ data.tar.gz: 56b87f0d83f5af72f8759f1d578b9d7da0c30c083b89c1f8e9c456a6bb894182ca29a195bfe7f35f4717f96e826f1284f5a39d597fdfde5c4d45b1796bad1b98
data/README.md CHANGED
@@ -1,89 +1,90 @@
1
- # PostgreSQL output plugins for Embulk
2
-
3
- PostgreSQL output plugins for Embulk loads records to PostgreSQL.
4
-
5
- ## Overview
6
-
7
- * **Plugin type**: output
8
- * **Load all or nothing**: depnds on the mode. see bellow.
9
- * **Resume supported**: depnds on the mode. see bellow.
10
-
11
- ## Configuration
12
-
13
- - **host**: database host name (string, required)
14
- - **port**: database port number (integer, default: 5432)
15
- - **user**: database login user name (string, required)
16
- - **password**: database login password (string, default: "")
17
- - **database**: destination database name (string, required)
18
- - **schema**: destination schema name (string, default: "public")
19
- - **table**: destination table name (string, required)
20
- - **options**: extra connection properties (hash, default: {})
21
- - **mode**: "replace", "merge" or "insert" (string, required)
22
- - **batch_size**: size of a single batch insert (integer, default: 16777216)
23
- - **default_timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp into a SQL string. This default_timezone option is used to control the timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
24
- - **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
25
- - **type**: type of a column when this plugin creates new tables (e.g. `VARCHAR(255)`, `INTEGER NOT NULL UNIQUE`). This used when this plugin creates intermediate tables (insert, truncate_insert and merge modes), when it creates the target table (insert_direct and replace modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. `BIGINT` if input column type is long, `BOOLEAN` if boolean, `DOUBLE PRECISION` if double, `CLOB` if string, `TIMESTAMP WITH TIME ZONE` if timestamp)
26
- - **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on input column type. Available values options are: `byte`, `short`, `int`, `long`, `double`, `float`, `boolean`, `string`, `nstring`, `date`, `time`, `timestamp`, `decimal`, `null`, `pass`)
27
- - **timestamp_format**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. This timestamp_format option is used to control the format of the timestamp. (string, default: `%Y-%m-%d %H:%M:%S.%6N`)
28
- - **timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp value into a SQL string. In this cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
29
-
30
- ### Modes
31
-
32
- * **insert**:
33
- * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, runs `INSERT INTO <target_table> SELECT * FROM <intermediate_table_1> UNION ALL SELECT * FROM <intermediate_table_2> UNION ALL ...` query.
34
- * Transactional: Yes. This mode successfully writes all rows, or fails with writing zero rows.
35
- * Resumable: Yes.
36
- * **insert_direct**:
37
- * Behavior: This mode inserts rows to the target table directly.
38
- * Transactional: No. If fails, the target table could have some rows inserted.
39
- * Resumable: No.
40
- * **truncate_insert**:
41
- * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
42
- * Transactional: Yes.
43
- * Resumable: Yes.
44
- * **merge**:
45
- * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, runs `with updated AS (UPDATE .... RETURNING ...) INSERT INTO ....` query.
46
- * Transactional: Yes.
47
- * Resumable: Yes.
48
- * **replace**:
49
- * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
50
- * Transactional: Yes.
51
- * Resumable: No.
52
-
53
- ### Example
54
-
55
- ```yaml
56
- out:
57
- type: postgresql
58
- host: localhost
59
- user: pg
60
- password: ""
61
- database: my_database
62
- table: my_table
63
- mode: insert
64
- ```
65
-
66
- Advanced configuration:
67
-
68
- ```yaml
69
- out:
70
- type: postgresql
71
- host: localhost
72
- user: pg
73
- password: ""
74
- database: my_database
75
- table: my_table
76
- options: {loglevel: 2}
77
- mode: insert_direct
78
- column_options:
79
- my_col_1: {type: 'BIGSERIAL'}
80
- my_col_3: {type: 'INT NOT NULL'}
81
- my_col_4: {value_type: string, timestamp_format: `%Y-%m-%d %H:%M:%S %z`, timezone: '-0700'}
82
- my_col_5: {type: 'DECIMAL(18,9)', value_type: pass}
83
- ```
84
-
85
- ### Build
86
-
87
- ```
88
- $ ./gradlew gem
89
- ```
1
+ # PostgreSQL output plugins for Embulk
2
+
3
+ PostgreSQL output plugins for Embulk loads records to PostgreSQL.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: output
8
+ * **Load all or nothing**: depnds on the mode. see bellow.
9
+ * **Resume supported**: depnds on the mode. see bellow.
10
+
11
+ ## Configuration
12
+
13
+ - **host**: database host name (string, required)
14
+ - **port**: database port number (integer, default: 5432)
15
+ - **user**: database login user name (string, required)
16
+ - **password**: database login password (string, default: "")
17
+ - **database**: destination database name (string, required)
18
+ - **schema**: destination schema name (string, default: "public")
19
+ - **table**: destination table name (string, required)
20
+ - **options**: extra connection properties (hash, default: {})
21
+ - **mode**: "replace", "merge" or "insert" (string, required)
22
+ - **ssl**: enables SSL. data will be encrypted but CA or certification will not be verified (boolean, default: false)
23
+ - **batch_size**: size of a single batch insert (integer, default: 16777216)
24
+ - **default_timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp into a SQL string. This default_timezone option is used to control the timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
25
+ - **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
26
+ - **type**: type of a column when this plugin creates new tables (e.g. `VARCHAR(255)`, `INTEGER NOT NULL UNIQUE`). This used when this plugin creates intermediate tables (insert, truncate_insert and merge modes), when it creates the target table (insert_direct and replace modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. `BIGINT` if input column type is long, `BOOLEAN` if boolean, `DOUBLE PRECISION` if double, `CLOB` if string, `TIMESTAMP WITH TIME ZONE` if timestamp)
27
+ - **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on input column type. Available values options are: `byte`, `short`, `int`, `long`, `double`, `float`, `boolean`, `string`, `nstring`, `date`, `time`, `timestamp`, `decimal`, `null`, `pass`)
28
+ - **timestamp_format**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. This timestamp_format option is used to control the format of the timestamp. (string, default: `%Y-%m-%d %H:%M:%S.%6N`)
29
+ - **timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp value into a SQL string. In this cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
30
+
31
+ ### Modes
32
+
33
+ * **insert**:
34
+ * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, runs `INSERT INTO <target_table> SELECT * FROM <intermediate_table_1> UNION ALL SELECT * FROM <intermediate_table_2> UNION ALL ...` query.
35
+ * Transactional: Yes. This mode successfully writes all rows, or fails with writing zero rows.
36
+ * Resumable: Yes.
37
+ * **insert_direct**:
38
+ * Behavior: This mode inserts rows to the target table directly.
39
+ * Transactional: No. If fails, the target table could have some rows inserted.
40
+ * Resumable: No.
41
+ * **truncate_insert**:
42
+ * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
43
+ * Transactional: Yes.
44
+ * Resumable: Yes.
45
+ * **merge**:
46
+ * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, runs `with updated AS (UPDATE .... RETURNING ...) INSERT INTO ....` query.
47
+ * Transactional: Yes.
48
+ * Resumable: Yes.
49
+ * **replace**:
50
+ * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
51
+ * Transactional: Yes.
52
+ * Resumable: No.
53
+
54
+ ### Example
55
+
56
+ ```yaml
57
+ out:
58
+ type: postgresql
59
+ host: localhost
60
+ user: pg
61
+ password: ""
62
+ database: my_database
63
+ table: my_table
64
+ mode: insert
65
+ ```
66
+
67
+ Advanced configuration:
68
+
69
+ ```yaml
70
+ out:
71
+ type: postgresql
72
+ host: localhost
73
+ user: pg
74
+ password: ""
75
+ database: my_database
76
+ table: my_table
77
+ options: {loglevel: 2}
78
+ mode: insert_direct
79
+ column_options:
80
+ my_col_1: {type: 'BIGSERIAL'}
81
+ my_col_3: {type: 'INT NOT NULL'}
82
+ my_col_4: {value_type: string, timestamp_format: `%Y-%m-%d %H:%M:%S %z`, timezone: '-0700'}
83
+ my_col_5: {type: 'DECIMAL(18,9)', value_type: pass}
84
+ ```
85
+
86
+ ### Build
87
+
88
+ ```
89
+ $ ./gradlew gem
90
+ ```
data/build.gradle CHANGED
@@ -1,7 +1,7 @@
1
- dependencies {
2
- compile project(':embulk-output-jdbc')
3
-
4
- compile 'org.postgresql:postgresql:9.4-1200-jdbc41'
5
-
6
- testCompile project(':embulk-output-jdbc').sourceSets.test.output
7
- }
1
+ dependencies {
2
+ compile project(':embulk-output-jdbc')
3
+
4
+ compile 'org.postgresql:postgresql:9.4-1205-jdbc41'
5
+
6
+ testCompile project(':embulk-output-jdbc').sourceSets.test.output
7
+ }
@@ -1,3 +1,3 @@
1
- Embulk::JavaPlugin.register_output(
2
- :postgresql, "org.embulk.output.PostgreSQLOutputPlugin",
3
- File.expand_path('../../../../classpath', __FILE__))
1
+ Embulk::JavaPlugin.register_output(
2
+ :postgresql, "org.embulk.output.PostgreSQLOutputPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))
@@ -1,165 +1,166 @@
1
- package org.embulk.output;
2
-
3
- import java.util.List;
4
- import java.util.Properties;
5
- import java.io.IOException;
6
- import java.sql.SQLException;
7
- import com.google.common.base.Optional;
8
- import com.google.common.collect.ImmutableSet;
9
- import org.embulk.config.Config;
10
- import org.embulk.config.ConfigDefault;
11
- import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
12
- import org.embulk.output.jdbc.BatchInsert;
13
- import org.embulk.output.postgresql.PostgreSQLOutputConnector;
14
- import org.embulk.output.postgresql.PostgreSQLCopyBatchInsert;
15
-
16
- import com.google.common.collect.ImmutableList;
17
- import java.sql.Types;
18
- import org.embulk.spi.Schema;
19
- import org.embulk.spi.ColumnVisitor;
20
- import org.embulk.spi.Column;
21
- import org.embulk.output.jdbc.JdbcColumn;
22
- import org.embulk.output.jdbc.JdbcSchema;
23
-
24
- public class PostgreSQLOutputPlugin
25
- extends AbstractJdbcOutputPlugin
26
- {
27
- public interface PostgreSQLPluginTask
28
- extends PluginTask
29
- {
30
- @Config("host")
31
- public String getHost();
32
-
33
- @Config("port")
34
- @ConfigDefault("5432")
35
- public int getPort();
36
-
37
- @Config("user")
38
- public String getUser();
39
-
40
- @Config("password")
41
- @ConfigDefault("\"\"")
42
- public String getPassword();
43
-
44
- @Config("database")
45
- public String getDatabase();
46
-
47
- @Config("schema")
48
- @ConfigDefault("\"public\"")
49
- public String getSchema();
50
- }
51
-
52
- @Override
53
- protected Class<? extends PluginTask> getTaskClass()
54
- {
55
- return PostgreSQLPluginTask.class;
56
- }
57
-
58
- @Override
59
- protected Features getFeatures(PluginTask task)
60
- {
61
- return new Features()
62
- .setMaxTableNameLength(30)
63
- .setSupportedModes(ImmutableSet.of(Mode.INSERT, Mode.INSERT_DIRECT, Mode.MERGE, Mode.TRUNCATE_INSERT, Mode.REPLACE))
64
- .setIgnoreMergeKeys(false);
65
- }
66
-
67
- @Override
68
- protected PostgreSQLOutputConnector getConnector(PluginTask task, boolean retryableMetadataOperation)
69
- {
70
- PostgreSQLPluginTask t = (PostgreSQLPluginTask) task;
71
-
72
- String url = String.format("jdbc:postgresql://%s:%d/%s",
73
- t.getHost(), t.getPort(), t.getDatabase());
74
-
75
- Properties props = new Properties();
76
- props.setProperty("loginTimeout", "300"); // seconds
77
- props.setProperty("socketTimeout", "1800"); // seconds
78
-
79
- // Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
80
- // Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
81
- props.setProperty("tcpKeepAlive", "true");
82
-
83
- // TODO
84
- //switch t.getSssl() {
85
- //when "disable":
86
- // break;
87
- //when "enable":
88
- // props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation
89
- //when "verify":
90
- // props.setProperty("ssl", "true");
91
- // break;
92
- //}
93
-
94
- if (!retryableMetadataOperation) {
95
- // non-retryable batch operation uses longer timeout
96
- props.setProperty("loginTimeout", "300"); // seconds
97
- props.setProperty("socketTimeout", "28800"); // seconds
98
- }
99
-
100
- props.putAll(t.getOptions());
101
-
102
- props.setProperty("user", t.getUser());
103
- logger.info("Connecting to {} options {}", url, props);
104
- props.setProperty("password", t.getPassword());
105
-
106
- return new PostgreSQLOutputConnector(url, props, t.getSchema());
107
- }
108
-
109
- @Override
110
- protected BatchInsert newBatchInsert(PluginTask task, Optional<List<String>> mergeKeys) throws IOException, SQLException
111
- {
112
- if (mergeKeys.isPresent()) {
113
- throw new UnsupportedOperationException("PostgreSQL output plugin doesn't support 'merge_direct' mode. Use 'merge' mode instead.");
114
- }
115
- return new PostgreSQLCopyBatchInsert(getConnector(task, true));
116
- }
117
-
118
- // TODO This is almost copy from AbstractJdbcOutputPlugin excepting type of TIMESTAMP -> TIMESTAMP WITH TIME ZONE.
119
- // AbstractJdbcOutputPlugin should have better extensibility.
120
- @Override
121
- protected JdbcSchema newJdbcSchemaForNewTable(Schema schema)
122
- {
123
- final ImmutableList.Builder<JdbcColumn> columns = ImmutableList.builder();
124
- for (Column c : schema.getColumns()) {
125
- final String columnName = c.getName();
126
- c.visit(new ColumnVisitor() {
127
- public void booleanColumn(Column column)
128
- {
129
- columns.add(JdbcColumn.newGenericTypeColumn(
130
- columnName, Types.BOOLEAN, "BOOLEAN",
131
- 1, 0, false, false));
132
- }
133
-
134
- public void longColumn(Column column)
135
- {
136
- columns.add(JdbcColumn.newGenericTypeColumn(
137
- columnName, Types.BIGINT, "BIGINT",
138
- 22, 0, false, false));
139
- }
140
-
141
- public void doubleColumn(Column column)
142
- {
143
- columns.add(JdbcColumn.newGenericTypeColumn(
144
- columnName, Types.FLOAT, "DOUBLE PRECISION",
145
- 24, 0, false, false));
146
- }
147
-
148
- public void stringColumn(Column column)
149
- {
150
- columns.add(JdbcColumn.newGenericTypeColumn(
151
- columnName, Types.CLOB, "CLOB",
152
- 4000, 0, false, false)); // TODO size type param
153
- }
154
-
155
- public void timestampColumn(Column column)
156
- {
157
- columns.add(JdbcColumn.newGenericTypeColumn(
158
- columnName, Types.TIMESTAMP, "TIMESTAMP WITH TIME ZONE",
159
- 26, 0, false, false)); // size type param is from postgresql
160
- }
161
- });
162
- }
163
- return new JdbcSchema(columns.build());
164
- }
165
- }
1
+ package org.embulk.output;
2
+
3
+ import java.util.List;
4
+ import java.util.Properties;
5
+ import java.io.IOException;
6
+ import java.sql.SQLException;
7
+ import com.google.common.base.Optional;
8
+ import com.google.common.collect.ImmutableSet;
9
+ import org.embulk.config.Config;
10
+ import org.embulk.config.ConfigDefault;
11
+ import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
12
+ import org.embulk.output.jdbc.BatchInsert;
13
+ import org.embulk.output.postgresql.PostgreSQLOutputConnector;
14
+ import org.embulk.output.postgresql.PostgreSQLCopyBatchInsert;
15
+
16
+ import com.google.common.collect.ImmutableList;
17
+ import java.sql.Types;
18
+ import org.embulk.spi.Schema;
19
+ import org.embulk.spi.ColumnVisitor;
20
+ import org.embulk.spi.Column;
21
+ import org.embulk.output.jdbc.JdbcColumn;
22
+ import org.embulk.output.jdbc.JdbcSchema;
23
+
24
+ public class PostgreSQLOutputPlugin
25
+ extends AbstractJdbcOutputPlugin
26
+ {
27
+ public interface PostgreSQLPluginTask
28
+ extends PluginTask
29
+ {
30
+ @Config("host")
31
+ public String getHost();
32
+
33
+ @Config("port")
34
+ @ConfigDefault("5432")
35
+ public int getPort();
36
+
37
+ @Config("user")
38
+ public String getUser();
39
+
40
+ @Config("password")
41
+ @ConfigDefault("\"\"")
42
+ public String getPassword();
43
+
44
+ @Config("database")
45
+ public String getDatabase();
46
+
47
+ @Config("schema")
48
+ @ConfigDefault("\"public\"")
49
+ public String getSchema();
50
+
51
+ @Config("ssl")
52
+ @ConfigDefault("false")
53
+ public boolean getSsl();
54
+ }
55
+
56
+ @Override
57
+ protected Class<? extends PluginTask> getTaskClass()
58
+ {
59
+ return PostgreSQLPluginTask.class;
60
+ }
61
+
62
+ @Override
63
+ protected Features getFeatures(PluginTask task)
64
+ {
65
+ return new Features()
66
+ .setMaxTableNameLength(30)
67
+ .setSupportedModes(ImmutableSet.of(Mode.INSERT, Mode.INSERT_DIRECT, Mode.MERGE, Mode.TRUNCATE_INSERT, Mode.REPLACE))
68
+ .setIgnoreMergeKeys(false);
69
+ }
70
+
71
+ @Override
72
+ protected PostgreSQLOutputConnector getConnector(PluginTask task, boolean retryableMetadataOperation)
73
+ {
74
+ PostgreSQLPluginTask t = (PostgreSQLPluginTask) task;
75
+
76
+ String url = String.format("jdbc:postgresql://%s:%d/%s",
77
+ t.getHost(), t.getPort(), t.getDatabase());
78
+
79
+ Properties props = new Properties();
80
+ props.setProperty("loginTimeout", "300"); // seconds
81
+ props.setProperty("socketTimeout", "1800"); // seconds
82
+
83
+ // Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
84
+ // Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
85
+ props.setProperty("tcpKeepAlive", "true");
86
+
87
+ if (t.getSsl()) {
88
+ // TODO add ssl_verify (boolean) option to allow users to verify certification.
89
+ // see embulk-input-ftp for SSL implementation.
90
+ props.setProperty("ssl", "true");
91
+ props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory"); // disable server-side validation
92
+ }
93
+ // setting ssl=false enables SSL. See org.postgresql.core.v3.openConnectionImpl.
94
+
95
+ if (!retryableMetadataOperation) {
96
+ // non-retryable batch operation uses longer timeout
97
+ props.setProperty("loginTimeout", "300"); // seconds
98
+ props.setProperty("socketTimeout", "28800"); // seconds
99
+ }
100
+
101
+ props.putAll(t.getOptions());
102
+
103
+ props.setProperty("user", t.getUser());
104
+ logger.info("Connecting to {} options {}", url, props);
105
+ props.setProperty("password", t.getPassword());
106
+
107
+ return new PostgreSQLOutputConnector(url, props, t.getSchema());
108
+ }
109
+
110
+ @Override
111
+ protected BatchInsert newBatchInsert(PluginTask task, Optional<List<String>> mergeKeys) throws IOException, SQLException
112
+ {
113
+ if (mergeKeys.isPresent()) {
114
+ throw new UnsupportedOperationException("PostgreSQL output plugin doesn't support 'merge_direct' mode. Use 'merge' mode instead.");
115
+ }
116
+ return new PostgreSQLCopyBatchInsert(getConnector(task, true));
117
+ }
118
+
119
+ // TODO This is almost copy from AbstractJdbcOutputPlugin excepting type of TIMESTAMP -> TIMESTAMP WITH TIME ZONE.
120
+ // AbstractJdbcOutputPlugin should have better extensibility.
121
+ @Override
122
+ protected JdbcSchema newJdbcSchemaForNewTable(Schema schema)
123
+ {
124
+ final ImmutableList.Builder<JdbcColumn> columns = ImmutableList.builder();
125
+ for (Column c : schema.getColumns()) {
126
+ final String columnName = c.getName();
127
+ c.visit(new ColumnVisitor() {
128
+ public void booleanColumn(Column column)
129
+ {
130
+ columns.add(JdbcColumn.newGenericTypeColumn(
131
+ columnName, Types.BOOLEAN, "BOOLEAN",
132
+ 1, 0, false, false));
133
+ }
134
+
135
+ public void longColumn(Column column)
136
+ {
137
+ columns.add(JdbcColumn.newGenericTypeColumn(
138
+ columnName, Types.BIGINT, "BIGINT",
139
+ 22, 0, false, false));
140
+ }
141
+
142
+ public void doubleColumn(Column column)
143
+ {
144
+ columns.add(JdbcColumn.newGenericTypeColumn(
145
+ columnName, Types.FLOAT, "DOUBLE PRECISION",
146
+ 24, 0, false, false));
147
+ }
148
+
149
+ public void stringColumn(Column column)
150
+ {
151
+ columns.add(JdbcColumn.newGenericTypeColumn(
152
+ columnName, Types.CLOB, "CLOB",
153
+ 4000, 0, false, false)); // TODO size type param
154
+ }
155
+
156
+ public void timestampColumn(Column column)
157
+ {
158
+ columns.add(JdbcColumn.newGenericTypeColumn(
159
+ columnName, Types.TIMESTAMP, "TIMESTAMP WITH TIME ZONE",
160
+ 26, 0, false, false)); // size type param is from postgresql
161
+ }
162
+ });
163
+ }
164
+ return new JdbcSchema(columns.build());
165
+ }
166
+ }