cmd

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 19 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:"Auto re-authenticate on auth failure"`
	NoAutoLogin bool   `help:"Disable auto re-authentication"`
	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"`
}

QueryCmd groups query management subcommands

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" default:"30" help:"Query timeout in seconds (5-50)"`
	Use           string `short:"u" help:"Default catalog[.schema] for query"`
	Async         bool   `help:"Submit query and return immediately, printing statement ID"`
}

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