Skip to content

Commit 91d572e

Browse files
authored
Merge pull request #5 from trocco-io/add-user-agent-parameter-to-config
Add user-agent parameter to config
2 parents 6d4cfd1 + a7cff7b commit 91d572e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Databricks input plugin for Embulk loads records from Databricks.
1111

1212
- **driver_path**: path to the jar file of the JDBC driver. If not set, [the bundled JDBC driver](https://docs.databricks.com/en/integrations/jdbc/index.html) will be used. (string, optional)
1313
- **options**: extra JDBC properties (hash, default: {})
14+
- **user_agent**: set user agent property to JDBC connection. If 'UserAgentEntry' property is specified in the **options**, it will be overwritten by this value. (hash, optional)
15+
- **product_name**: product name of user agent (string, default: "unknown")
16+
- **product_version**: product version of user agent (string, default: "0.0.0")
1417
- **server_hostname**: The Databricks compute resource’s Server Hostname value, see [Compute settings for the Databricks JDBC Driver](https://docs.databricks.com/en/integrations/jdbc/compute.html). (string, required)
1518
- **http_path**: The Databricks compute resource’s HTTP Path value, see [Compute settings for the Databricks JDBC Driver](https://docs.databricks.com/en/integrations/jdbc/compute.html). (string, required)
1619
- **personal_access_token**: The Databaricks personal_access_token, see [Authentication settings for the Databricks JDBC Driver](https://docs.databricks.com/en/integrations/jdbc/authentication.html#authentication-pat). (string, required)

src/main/java/org/embulk/input/DatabricksInputPlugin.java

100644100755
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.embulk.spi.Schema;
1212
import org.embulk.util.config.Config;
1313
import org.embulk.util.config.ConfigDefault;
14+
import org.embulk.util.config.Task;
1415
import org.slf4j.Logger;
1516
import org.slf4j.LoggerFactory;
1617

@@ -39,6 +40,20 @@ public interface DatabricksPluginTask extends PluginTask {
3940
@Config("schema_name")
4041
@ConfigDefault("null")
4142
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+
}
4257
}
4358

4459
@Override
@@ -76,6 +91,11 @@ protected JdbcInputConnection newConnection(PluginTask task) throws SQLException
7691
}
7792
props.putAll(t.getOptions());
7893

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+
7999
logConnectionProperties(url, props);
80100
Connection c = DriverManager.getConnection(url, props);
81101
return new DatabricksInputConnection(

0 commit comments

Comments
 (0)