Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/oauth-m2m
Browse files Browse the repository at this point in the history
  • Loading branch information
chikamura committed Aug 16, 2024
2 parents 0c56482 + 91d572e commit 9356781
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Databricks input plugin for Embulk loads records from Databricks.

- **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)
- **options**: extra JDBC properties (hash, default: {})
- **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)
- **product_name**: product name of user agent (string, default: "unknown")
- **product_version**: product version of user agent (string, default: "0.0.0")
- **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)
- **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)
- **auth_type**: The Databricks authentication type, personal access token (PAT)-based or machine-to-machine (M2M) authentication. (`pat`, `oauth-m2m`, default: `pat`)
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/embulk/input/DatabricksInputPlugin.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.embulk.spi.Schema;
import org.embulk.util.config.Config;
import org.embulk.util.config.ConfigDefault;
import org.embulk.util.config.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

@Config("user_agent")
@ConfigDefault("{}")
public UserAgentEntry getUserAgentEntry();

public interface UserAgentEntry extends Task {
@Config("product_name")
@ConfigDefault("\"unknown\"")
public String getProductName();

@Config("product_version")
@ConfigDefault("\"0.0.0\"")
public String getProductVersion();
}

static String fetchPersonalAccessToken(DatabricksPluginTask t) {
return validatePresence(t.getPersonalAccessToken(), "personal_access_token");
}
Expand Down Expand Up @@ -123,6 +138,11 @@ protected JdbcInputConnection newConnection(PluginTask task) throws SQLException
}
props.putAll(t.getOptions());

// overwrite UserAgentEntry property if the same property is set in options
String productName = t.getUserAgentEntry().getProductName();
String productVersion = t.getUserAgentEntry().getProductVersion();
props.put("UserAgentEntry", productName + "/" + productVersion);

logConnectionProperties(url, props);
Connection c = DriverManager.getConnection(url, props);
return new DatabricksInputConnection(
Expand Down

0 comments on commit 9356781

Please sign in to comment.