Documentation ¶
Overview ¶
This API allows execution of Python, Scala, SQL, or R commands on running Databricks Clusters.
Index ¶
- func TrimLeadingWhitespace(commandStr string) (newCommand string)
- type CancelCommand
- type Command
- type CommandExecutionAPI
- func (a *CommandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error
- func (a *CommandExecutionAPI) CancelAndWait(ctx context.Context, cancelCommand CancelCommand, ...) (*CommandStatusResponse, error)
- func (a *CommandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error)
- func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error)
- func (a *CommandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error)
- func (a *CommandExecutionAPI) CreateAndWait(ctx context.Context, createContext CreateContext, ...) (*ContextStatusResponse, error)
- func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error
- func (a *CommandExecutionAPI) Execute(ctx context.Context, request Command) (*Created, error)
- func (a *CommandExecutionAPI) ExecuteAndWait(ctx context.Context, command Command, ...) (*CommandStatusResponse, error)
- func (a *CommandExecutionAPI) Impl() CommandExecutionService
- func (a *CommandExecutionAPI) WithImpl(impl CommandExecutionService) *CommandExecutionAPI
- type CommandExecutionService
- type CommandExecutor
- type CommandMock
- type CommandStatus
- type CommandStatusRequest
- type CommandStatusResponse
- type CommandsHighLevelAPI
- type ContextStatus
- type ContextStatusRequest
- type ContextStatusResponse
- type CreateContext
- type Created
- type DestroyContext
- type Language
- type ResultType
- type Results
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TrimLeadingWhitespace ¶
TrimLeadingWhitespace removes leading whitespace, so that Python code blocks that are embedded into Go code still could be interpreted properly.
Types ¶
type CancelCommand ¶
type CommandExecutionAPI ¶
type CommandExecutionAPI struct {
// contains filtered or unexported fields
}
This API allows execution of Python, Scala, SQL, or R commands on running Databricks Clusters.
func NewCommandExecution ¶
func NewCommandExecution(client *client.DatabricksClient) *CommandExecutionAPI
func (*CommandExecutionAPI) Cancel ¶
func (a *CommandExecutionAPI) Cancel(ctx context.Context, request CancelCommand) error
Cancel a command.
Cancels a currently running command within an execution context.
The command ID is obtained from a prior successful call to __execute__.
func (*CommandExecutionAPI) CancelAndWait ¶
func (a *CommandExecutionAPI) CancelAndWait(ctx context.Context, cancelCommand CancelCommand, options ...retries.Option[CommandStatusResponse]) (*CommandStatusResponse, error)
Calls CommandExecutionAPI.Cancel and waits to reach Cancelled state
You can override the default timeout of 20 minutes by calling adding retries.Timeout[CommandStatusResponse](60*time.Minute) functional option.
func (*CommandExecutionAPI) CommandStatus ¶
func (a *CommandExecutionAPI) CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error)
Get command info.
Gets the status of and, if available, the results from a currently executing command.
The command ID is obtained from a prior successful call to __execute__.
func (*CommandExecutionAPI) ContextStatus ¶
func (a *CommandExecutionAPI) ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error)
Get status.
Gets the status for an execution context.
func (*CommandExecutionAPI) Create ¶
func (a *CommandExecutionAPI) Create(ctx context.Context, request CreateContext) (*Created, error)
Create an execution context.
Creates an execution context for running cluster commands.
If successful, this method returns the ID of the new execution context.
func (*CommandExecutionAPI) CreateAndWait ¶
func (a *CommandExecutionAPI) CreateAndWait(ctx context.Context, createContext CreateContext, options ...retries.Option[ContextStatusResponse]) (*ContextStatusResponse, error)
Calls CommandExecutionAPI.Create and waits to reach Running state
You can override the default timeout of 20 minutes by calling adding retries.Timeout[ContextStatusResponse](60*time.Minute) functional option.
func (*CommandExecutionAPI) Destroy ¶
func (a *CommandExecutionAPI) Destroy(ctx context.Context, request DestroyContext) error
Delete an execution context.
Deletes an execution context.
func (*CommandExecutionAPI) Execute ¶
Run a command.
Runs a cluster command in the given execution context, using the provided language.
If successful, it returns an ID for tracking the status of the command's execution.
func (*CommandExecutionAPI) ExecuteAndWait ¶
func (a *CommandExecutionAPI) ExecuteAndWait(ctx context.Context, command Command, options ...retries.Option[CommandStatusResponse]) (*CommandStatusResponse, error)
Calls CommandExecutionAPI.Execute and waits to reach Finished or Error state
You can override the default timeout of 20 minutes by calling adding retries.Timeout[CommandStatusResponse](60*time.Minute) functional option.
func (*CommandExecutionAPI) Impl ¶
func (a *CommandExecutionAPI) Impl() CommandExecutionService
Impl returns low-level CommandExecution API implementation
func (*CommandExecutionAPI) WithImpl ¶
func (a *CommandExecutionAPI) WithImpl(impl CommandExecutionService) *CommandExecutionAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
type CommandExecutionService ¶
type CommandExecutionService interface { // Cancel a command. // // Cancels a currently running command within an execution context. // // The command ID is obtained from a prior successful call to __execute__. Cancel(ctx context.Context, request CancelCommand) error // Get command info. // // Gets the status of and, if available, the results from a currently // executing command. // // The command ID is obtained from a prior successful call to __execute__. CommandStatus(ctx context.Context, request CommandStatusRequest) (*CommandStatusResponse, error) // Get status. // // Gets the status for an execution context. ContextStatus(ctx context.Context, request ContextStatusRequest) (*ContextStatusResponse, error) // Create an execution context. // // Creates an execution context for running cluster commands. // // If successful, this method returns the ID of the new execution context. Create(ctx context.Context, request CreateContext) (*Created, error) // Delete an execution context. // // Deletes an execution context. Destroy(ctx context.Context, request DestroyContext) error // Run a command. // // Runs a cluster command in the given execution context, using the provided // language. // // If successful, it returns an ID for tracking the status of the command's // execution. Execute(ctx context.Context, request Command) (*Created, error) }
This API allows execution of Python, Scala, SQL, or R commands on running Databricks Clusters.
type CommandExecutor ¶
type CommandExecutor interface {
Execute(ctx context.Context, clusterID, language, commandStr string) Results
}
CommandExecutor creates a spark context and executes a command and then closes context
func NewCommandExecutor ¶
func NewCommandExecutor(client *client.DatabricksClient) CommandExecutor
type CommandMock ¶
CommandMock mocks the execution of command
type CommandStatus ¶
type CommandStatus string
const CommandStatusCancelled CommandStatus = `Cancelled`
const CommandStatusCancelling CommandStatus = `Cancelling`
const CommandStatusError CommandStatus = `Error`
const CommandStatusFinished CommandStatus = `Finished`
const CommandStatusQueued CommandStatus = `Queued`
const CommandStatusRunning CommandStatus = `Running`
func (*CommandStatus) Set ¶ added in v0.2.0
func (cs *CommandStatus) Set(v string) error
Set raw string value and validate it against allowed values
func (*CommandStatus) String ¶ added in v0.2.0
func (cs *CommandStatus) String() string
String representation for fmt.Print
func (*CommandStatus) Type ¶ added in v0.2.0
func (cs *CommandStatus) Type() string
Type always returns CommandStatus to satisfy [pflag.Value] interface
type CommandStatusRequest ¶
type CommandStatusRequest struct { ClusterId string `json:"-" url:"clusterId"` CommandId string `json:"-" url:"commandId"` ContextId string `json:"-" url:"contextId"` }
Get command info
type CommandStatusResponse ¶
type CommandStatusResponse struct { Id string `json:"id,omitempty"` Results *Results `json:"results,omitempty"` Status CommandStatus `json:"status,omitempty"` }
type CommandsHighLevelAPI ¶
type CommandsHighLevelAPI struct {
// contains filtered or unexported fields
}
CommandsHighLevelAPI exposes more friendly wrapper over command execution
type ContextStatus ¶
type ContextStatus string
const ContextStatusError ContextStatus = `Error`
const ContextStatusPending ContextStatus = `Pending`
const ContextStatusRunning ContextStatus = `Running`
func (*ContextStatus) Set ¶ added in v0.2.0
func (cs *ContextStatus) Set(v string) error
Set raw string value and validate it against allowed values
func (*ContextStatus) String ¶ added in v0.2.0
func (cs *ContextStatus) String() string
String representation for fmt.Print
func (*ContextStatus) Type ¶ added in v0.2.0
func (cs *ContextStatus) Type() string
Type always returns ContextStatus to satisfy [pflag.Value] interface
type ContextStatusRequest ¶
type ContextStatusRequest struct { ClusterId string `json:"-" url:"clusterId"` ContextId string `json:"-" url:"contextId"` }
Get status
type ContextStatusResponse ¶
type ContextStatusResponse struct { Id string `json:"id,omitempty"` Status ContextStatus `json:"status,omitempty"` }
type CreateContext ¶
type DestroyContext ¶
type Language ¶
type Language string
const LanguagePython Language = `python`
const LanguageScala Language = `scala`
const LanguageSql Language = `sql`
type ResultType ¶
type ResultType string
const ResultTypeError ResultType = `error`
const ResultTypeImage ResultType = `image`
const ResultTypeImages ResultType = `images`
const ResultTypeTable ResultType = `table`
const ResultTypeText ResultType = `text`
func (*ResultType) Set ¶ added in v0.2.0
func (rt *ResultType) Set(v string) error
Set raw string value and validate it against allowed values
func (*ResultType) String ¶ added in v0.2.0
func (rt *ResultType) String() string
String representation for fmt.Print
func (*ResultType) Type ¶ added in v0.2.0
func (rt *ResultType) Type() string
Type always returns ResultType to satisfy [pflag.Value] interface
type Results ¶
type Results struct { // The cause of the error Cause string `json:"cause,omitempty"` Data any `json:"data,omitempty"` // The image filename FileName string `json:"fileName,omitempty"` FileNames []string `json:"fileNames,omitempty"` // true if a JSON schema is returned instead of a string representation of // the Hive type. IsJsonSchema bool `json:"isJsonSchema,omitempty"` // internal field used by SDK Pos int `json:"pos,omitempty"` ResultType ResultType `json:"resultType,omitempty"` // The table schema Schema []map[string]any `json:"schema,omitempty"` // The summary of the error Summary string `json:"summary,omitempty"` // true if partial results are returned. Truncated bool `json:"truncated,omitempty"` }