|
11 | 11 | import org.embulk.spi.Schema; |
12 | 12 | import org.embulk.util.config.Config; |
13 | 13 | import org.embulk.util.config.ConfigDefault; |
| 14 | +import org.embulk.util.config.Task; |
14 | 15 | import org.slf4j.Logger; |
15 | 16 | import org.slf4j.LoggerFactory; |
16 | 17 |
|
@@ -39,6 +40,20 @@ public interface DatabricksPluginTask extends PluginTask { |
39 | 40 | @Config("schema_name") |
40 | 41 | @ConfigDefault("null") |
41 | 42 | public Optional<String> getSchemaName(); |
| 43 | + |
| 44 | + @Config("user_agent") |
| 45 | + @ConfigDefault("{}") |
| 46 | + public UserAgentEntry getUserAgentEntry(); |
| 47 | + |
| 48 | + public interface UserAgentEntry extends Task { |
| 49 | + @Config("product_name") |
| 50 | + @ConfigDefault("\"unknown\"") |
| 51 | + public String getProductName(); |
| 52 | + |
| 53 | + @Config("product_version") |
| 54 | + @ConfigDefault("\"0.0.0\"") |
| 55 | + public String getProductVersion(); |
| 56 | + } |
42 | 57 | } |
43 | 58 |
|
44 | 59 | @Override |
@@ -76,6 +91,11 @@ protected JdbcInputConnection newConnection(PluginTask task) throws SQLException |
76 | 91 | } |
77 | 92 | props.putAll(t.getOptions()); |
78 | 93 |
|
| 94 | + // overwrite UserAgentEntry property if the same property is set in options |
| 95 | + String productName = t.getUserAgentEntry().getProductName(); |
| 96 | + String productVersion = t.getUserAgentEntry().getProductVersion(); |
| 97 | + props.put("UserAgentEntry", productName + "/" + productVersion); |
| 98 | + |
79 | 99 | logConnectionProperties(url, props); |
80 | 100 | Connection c = DriverManager.getConnection(url, props); |
81 | 101 | return new DatabricksInputConnection( |
|
0 commit comments