Skip to content

Commit 4c1b68d

Browse files
authored
Merge pull request #69 from kenkoooo/main
Add `role` to config
2 parents 8d9b552 + 93ac09c commit 4c1b68d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Snowflake output plugin for Embulk loads records to Snowflake.
1919
- **database**: destination database name (string, required)
2020
- **schema**: destination schema name (string, default: "public")
2121
- **table**: destination table name (string, required)
22+
- **role**: role to execute queries (string, default: "")
2223
- **retry_limit**: max retry count for database operations (integer, default: 12). When intermediate table to create already created by another process, this plugin will retry with another table name to avoid collision.
2324
- **retry_wait**: initial retry wait time in milliseconds (integer, default: 1000 (1 second))
2425
- **max_retry_wait**: upper limit of retry wait, which will be doubled at every retry (integer, default: 1800000 (30 minutes))

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ public interface SnowflakePluginTask extends PluginTask {
6060
@ConfigDefault("\"public\"")
6161
public String getSchema();
6262

63+
@Config("role")
64+
@ConfigDefault("\"\"")
65+
public String getRole();
66+
6367
@Config("delete_stage")
6468
@ConfigDefault("false")
6569
public boolean getDeleteStage();
@@ -120,6 +124,9 @@ protected JdbcOutputConnector getConnector(PluginTask task, boolean retryableMet
120124
props.setProperty("warehouse", t.getWarehouse());
121125
props.setProperty("db", t.getDatabase());
122126
props.setProperty("schema", t.getSchema());
127+
if (!t.getRole().isEmpty()) {
128+
props.setProperty("role", t.getRole());
129+
}
123130

124131
// When CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX is false (default),
125132
// getMetaData().getColumns() returns columns of the tables which table name is

src/test/java/org/embulk/output/snowflake/TestSnowflakeOutputPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public void testConfigDefault() throws Exception {
208208
assertEquals("", task.getUser());
209209
assertEquals("", task.getPassword());
210210
assertEquals("public", task.getSchema());
211+
assertEquals("", task.getRole());
211212
assertEquals(false, task.getDeleteStage());
212213
}
213214

0 commit comments

Comments
 (0)