Help us shape the future of Go! Take the 2026 Go Developer Survey

cmd

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package cmd implements the dbq CLI commands.

Index

Constants

This section is empty.

Variables

View Source
var CLI struct {
	Workspace   string `env:"DBQ_WORKSPACE" help:"Databricks workspace"`
	Warehouse   string `env:"DBQ_WAREHOUSE" help:"SQL warehouse ID or name"`
	AutoLogin   bool   `help:"Force auto re-authentication, even when stderr is not a terminal"`
	NoAutoLogin bool   `help:"Disable auto re-authentication, even when stderr is a terminal"`
	Debug       bool   `help:"Enable debug output"`

	SQL        SQLCmd        `cmd:"" help:"Execute SQL query"`
	Query      QueryCmd      `cmd:"" help:"Manage async queries"`
	Warehouses WarehousesCmd `cmd:"" help:"List SQL warehouses"`
	Auth       AuthCmd       `cmd:"" help:"Authentication commands"`
	Cheatsheet CheatsheetCmd `cmd:"" help:"Print usage cheatsheet"`
}

Functions

func Run

func Run()

Types

type AuthCmd

type AuthCmd struct {
	Login  AuthLoginCmd  `cmd:"" help:"Authenticate with Databricks"`
	Status AuthStatusCmd `cmd:"" help:"Show current authentication status"`
}

AuthCmd groups authentication subcommands

type AuthLoginCmd

type AuthLoginCmd struct{}

AuthLoginCmd authenticates with Databricks

func (*AuthLoginCmd) Run

func (c *AuthLoginCmd) Run() error

type AuthStatusCmd

type AuthStatusCmd struct{}

AuthStatusCmd shows the current authentication status

func (*AuthStatusCmd) Run

func (c *AuthStatusCmd) Run() error

type CheatsheetCmd

type CheatsheetCmd struct{}

CheatsheetCmd prints a usage cheatsheet

func (*CheatsheetCmd) Run

func (c *CheatsheetCmd) Run() error

type OutputOptions

type OutputOptions struct {
	Output string `short:"o" help:"Output file; format is inferred from extension"`
	Format string `short:"f" default:"" help:"Output format (jsonl, json, csv, parquet, arrow, arrows)"`
}

OutputOptions provides shared flags for output destination and format.

func (*OutputOptions) WriteResult

func (o *OutputOptions) WriteResult(qr result.QueryResult) (int, error)

WriteResult writes query results to the configured output destination.

type QueryCancelCmd

type QueryCancelCmd struct {
	StatementID string `arg:"" help:"Statement ID to cancel"`
}

QueryCancelCmd cancels a running query.

func (*QueryCancelCmd) Run

func (c *QueryCancelCmd) Run() error

type QueryCmd

type QueryCmd struct {
	Status  QueryStatusCmd  `cmd:"" help:"Check status of an async query"`
	Wait    QueryWaitCmd    `cmd:"" help:"Wait for a query to complete"`
	Cancel  QueryCancelCmd  `cmd:"" help:"Cancel a running query"`
	Results QueryResultsCmd `cmd:"" help:"Fetch results of a completed query"`
	Metrics QueryMetricsCmd `cmd:"" help:"Show execution metrics for a query"`
	Info    QueryInfoCmd    `cmd:"" help:"Show query details (SQL text, status, timings) from query history"`
	List    QueryListCmd    `cmd:"" help:"List recent queries from query history"`
}

QueryCmd groups query management subcommands

type QueryInfoCmd added in v0.5.0

type QueryInfoCmd struct {
	StatementID string `arg:"" help:"Statement ID to look up"`
}

QueryInfoCmd shows query details (including the SQL text) from query history.

func (*QueryInfoCmd) Run added in v0.5.0

func (c *QueryInfoCmd) Run() error

type QueryListCmd added in v0.5.0

type QueryListCmd struct {
	MaxResults  int      `short:"n" default:"20" help:"Maximum number of queries to return (max 1000)"`
	Status      []string `help:"Filter by status (QUEUED, RUNNING, CANCELED, FAILED, FINISHED)"`
	WarehouseID []string `help:"Filter by warehouse ID"`
	User        string   `help:"Filter by numeric user ID; 'all' (or '*') for no filter; default is the current user" placeholder:"ID"`
	Summary     bool     `short:"s" help:"Print one summary line per query instead of full JSON"`
}

QueryListCmd lists recent queries from query history.

func (*QueryListCmd) Run added in v0.5.0

func (c *QueryListCmd) Run() error

type QueryMetricsCmd

type QueryMetricsCmd struct {
	StatementID string `arg:"" help:"Statement ID to fetch metrics for"`
}

QueryMetricsCmd prints query execution metrics as JSON.

func (*QueryMetricsCmd) Run

func (c *QueryMetricsCmd) Run() error

type QueryResultsCmd

type QueryResultsCmd struct {
	StatementID   string `arg:"" help:"Statement ID to fetch results for"`
	OutputOptions `embed:""`
}

QueryResultsCmd fetches results of a completed statement

func (*QueryResultsCmd) Run

func (c *QueryResultsCmd) Run() error

type QueryStatusCmd

type QueryStatusCmd struct {
	StatementID string `arg:"" help:"Statement ID to check"`
}

QueryStatusCmd checks the status of a submitted statement

func (*QueryStatusCmd) Run

func (c *QueryStatusCmd) Run() error

type QueryWaitCmd

type QueryWaitCmd struct {
	StatementID     string  `arg:"" help:"Statement ID to wait for"`
	Timeout         int     `short:"t" default:"300" help:"Maximum seconds to wait"`
	PollInterval    float64 `short:"i" default:"5" help:"Poll interval in seconds"`
	CancelOnTimeout bool    `help:"Cancel the query if the timeout is reached"`
}

QueryWaitCmd polls until a query reaches a terminal state.

func (*QueryWaitCmd) Run

func (c *QueryWaitCmd) Run() error

type SQLCmd

type SQLCmd struct {
	Query         string `arg:"" optional:"" help:"SQL query (or @file.sql)"`
	OutputOptions `embed:""`
	Limit         int64    `short:"l" default:"1000" help:"Maximum number of rows to return"`
	Timeout       *int     `short:"t" help:"Query timeout in seconds (default 30); values >50 poll until completion; ignored with --async"`
	PollInterval  float64  `short:"i" default:"5" help:"Poll interval in seconds when --timeout exceeds 50; ignored with --async"`
	Use           string   `short:"u" help:"Default catalog[.schema] for query"`
	Async         bool     `help:"Submit query and return immediately, printing statement ID"`
	Tag           []string `help:"Query tag (KEY=VALUE), repeatable" placeholder:"KEY=VALUE"`
}

SQLCmd executes SQL queries

func (*SQLCmd) Run

func (c *SQLCmd) Run() error

type WarehousesCmd

type WarehousesCmd struct{}

WarehousesCmd lists SQL warehouses

func (*WarehousesCmd) Run

func (c *WarehousesCmd) Run() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL