Skip to content

Commit 9356781

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/oauth-m2m
2 parents 0c56482 + 91d572e commit 9356781

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
- **auth_type**: The Databricks authentication type, personal access token (PAT)-based or machine-to-machine (M2M) authentication. (`pat`, `oauth-m2m`, default: `pat`)

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

100644100755
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.embulk.spi.Schema;
1414
import org.embulk.util.config.Config;
1515
import org.embulk.util.config.ConfigDefault;
16+
import org.embulk.util.config.Task;
1617
import org.slf4j.Logger;
1718
import org.slf4j.LoggerFactory;
1819

@@ -55,6 +56,20 @@ public interface DatabricksPluginTask extends PluginTask {
5556
@ConfigDefault("null")
5657
public Optional<String> getSchemaName();
5758

59+
@Config("user_agent")
60+
@ConfigDefault("{}")
61+
public UserAgentEntry getUserAgentEntry();
62+
63+
public interface UserAgentEntry extends Task {
64+
@Config("product_name")
65+
@ConfigDefault("\"unknown\"")
66+
public String getProductName();
67+
68+
@Config("product_version")
69+
@ConfigDefault("\"0.0.0\"")
70+
public String getProductVersion();
71+
}
72+
5873
static String fetchPersonalAccessToken(DatabricksPluginTask t) {
5974
return validatePresence(t.getPersonalAccessToken(), "personal_access_token");
6075
}
@@ -123,6 +138,11 @@ protected JdbcInputConnection newConnection(PluginTask task) throws SQLException
123138
}
124139
props.putAll(t.getOptions());
125140

141+
// overwrite UserAgentEntry property if the same property is set in options
142+
String productName = t.getUserAgentEntry().getProductName();
143+
String productVersion = t.getUserAgentEntry().getProductVersion();
144+
props.put("UserAgentEntry", productName + "/" + productVersion);
145+
126146
logConnectionProperties(url, props);
127147
Connection c = DriverManager.getConnection(url, props);
128148
return new DatabricksInputConnection(

0 commit comments

Comments
 (0)