RepoDatabricks (DBRX)Databricks (DBRX)published Jun 21, 2022seen 5d

databricks/databricks-sdk-go

Go

Open original ↗

Captured source

source ↗
published Jun 21, 2022seen 5dcaptured 13hhttp 200method plain

databricks/databricks-sdk-go

Description: Databricks SDK for Go

Language: Go

License: Apache-2.0

Stars: 78

Forks: 71

Open issues: 45

Created: 2022-06-21T13:49:58Z

Pushed: 2026-06-11T03:54:00Z

Default branch: main

Fork: no

Archived: no

README:

Databricks SDK for Go

![lines of code]()

Beta: This SDK is supported for production use cases, but we do expect future releases to have some interface changes; see [Interface stability](#interface-stability). We are keen to hear feedback from you on these SDKs. Please file issues, and we will address them | See documentation at Go Packages | See also the Terraform Provider | See also the SDK for Python | See also the SDK for Java

The Databricks SDK for Go includes functionality to accelerate development with Go for the Databricks Lakehouse. It covers all public Databricks REST API operations. The SDK's internal HTTP client is robust and handles failures on different levels by performing intelligent retries.

Contents

  • [Databricks SDK for Go](#databricks-sdk-for-go)
  • [Contents](#contents)
  • [Getting started](#getting-started)
  • [Authentication](#authentication)
  • [In this section](#in-this-section)
  • [Default authentication flow](#default-authentication-flow)
  • [Unified host support](#unified-host-support)
  • [Databricks native authentication](#databricks-native-authentication)
  • [Azure native authentication](#azure-native-authentication)
  • [Google Cloud Platform native authentication](#google-cloud-platform-native-authentication)
  • [Overriding .databrickscfg](#overriding-databrickscfg)
  • [Additional authentication configuration options](#additional-authentication-configuration-options)
  • [Custom credentials provider](#custom-credentials-provider)
  • [Code examples](#code-examples)
  • [Long-running operations](#long-running-operations)
  • [In this section](#in-this-section-1)
  • [Command execution on clusters](#command-execution-on-clusters)
  • [Cluster library management](#cluster-library-management)
  • [Advanced usage](#advanced-usage)
  • [Paginated responses](#paginated-responses)
  • [Retries](#retries)
  • [GetByName utility methods](#getbyname-utility-methods)
  • [Node type and Databricks Runtime selectors](#node-type-and-databricks-runtime-selectors)
  • [Integration with io interfaces for DBFS](#integration-with-io-interfaces-for-dbfs)
  • [Reading into and writing from buffers](#reading-into-and-writing-from-buffers)
  • [pflag.Value for enums](#pflagvalue-for-enums)
  • [User Agent Request Attribution](#user-agent-request-attribution)
  • [Error handling](#error-handling)
  • [Logging](#logging)
  • [Testing](#testing)
  • [Interface stability](#interface-stability)
  • [Go version support](#go-version-support)

Getting started

1. On your local development machine with Go already installed and a Go code project active, create a go.mod file to track your Go code's dependencies by running the go mod init command, for example:

go mod init sample

2. Take a dependency on the Databricks SDK for Go package by running the go mod edit -require command:

go mod edit -require github.com/databricks/databricks-sdk-go@latest

Your go.mod file should now look like this:

module sample

go 1.24

require github.com/databricks/databricks-sdk-go v0.9.0

// Indirect dependencies will go here.

3. Within your project, create a Go code file that imports the Databricks SDK for Go. The following example, in a file named main.go with the following contents, simply lists all the clusters in your Databricks workspace:

package main

import (
"context"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/compute"
)

func main() {
w := databricks.Must(databricks.NewWorkspaceClient())
all, err := w.Clusters.ListAll(context.Background(), compute.ListClustersRequest{})
if err != nil {
panic(err)
}
for _, c := range all {
println(c.ClusterName)
}
}

4. Add any misssing module dependencies by running the go mod tidy command:

go mod tidy

Note: If you get the error go: warning: "all" matched no packages, you forgot to add the preceding Go code file that imports the Databricks SDK for Go.

5. Grab copies of all packages needed to support builds and tests of packages in your main module, by running the go mod vendor command:

go mod vendor

6. Set up Databricks authentication on your local development machine by running `databricks configure` command, if you have not done so already. For details, see the next section, [Authentication](#authentication).

7. Run your Go code file, assuming a file named main.go, by running the go run command:

go run main.go

Assuming the preceding example code is run, the output is:

[TRACE] Loading config via environment
[TRACE] Loading config via config-file
...
[TRACE] Attempting to configure auth: pat
[TRACE] Attempting to configure auth: basic
[TRACE] Attempting to configure auth: azure-client-secret
...

Authentication

If you use Databricks configuration profiles or Databricks-specific environment variables for Databricks authentication, the only code required to start working with a Databricks workspace is the following code snippet, which instructs the Databricks SDK for Go to use its [default authentication flow](#default-authentication-flow):

w := databricks.Must(databricks.NewWorkspaceClient())
w./*press TAB for autocompletion*/

The conventional name for the variable that holds the workspace-level client of the Databricks SDK for Go is w, which is shorthand for workspace.

In this section

  • [Default authentication…

Excerpt shown — open the source for the full document.