Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Databricks output plugin for Embulk loads records to Databricks Delta Table.

- **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 and SDK 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)
- **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)
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/org/embulk/output/DatabricksOutputPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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 @@ -52,6 +53,20 @@ public interface DatabricksPluginTask extends PluginTask {
@Config("delete_stage_on_error")
@ConfigDefault("false")
public boolean getDeleteStageOnError();

@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();
}
}

@Override
Expand Down Expand Up @@ -92,6 +107,12 @@ protected JdbcOutputConnector getConnector(PluginTask task, boolean retryableMet
props.put("ConnCatalog", t.getCatalogName());
props.put("ConnSchema", t.getSchemaName());
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);
return new DatabricksOutputConnector(
url, props, t.getTransactionIsolation(), t.getCatalogName(), t.getSchemaName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.core.DatabricksConfig;
import com.databricks.sdk.core.UserAgent;
import com.databricks.sdk.service.catalog.VolumeType;
import java.io.InputStream;
import java.text.SimpleDateFormat;
Expand All @@ -11,9 +12,18 @@

public class DatabricksAPIClient {
public static DatabricksAPIClient create(DatabricksOutputPlugin.DatabricksPluginTask task) {
setUserAgent(task);

return new DatabricksAPIClient(createDatabricksConfig(task));
}

private static void setUserAgent(DatabricksOutputPlugin.DatabricksPluginTask task) {
String name = task.getUserAgentEntry().getProductName();
String version = task.getUserAgentEntry().getProductVersion();

UserAgent.withProduct(name, version);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

private final WorkspaceClient workspaceClient;

public DatabricksAPIClient(DatabricksConfig config) {
Expand Down