// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package online_tables
import (
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/spf13/cobra"
)
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var cmdOverrides []func(*cobra.Command)
func New() *cobra.Command {
cmd := &cobra.Command{
Use: "online-tables",
Short: `Online tables provide lower latency and higher QPS access to data from Delta tables.`,
Long: `Online tables provide lower latency and higher QPS access to data from Delta
tables.`,
GroupID: "catalog",
Annotations: map[string]string{
"package": "catalog",
},
}
// Add methods
cmd.AddCommand(newCreate())
cmd.AddCommand(newDelete())
cmd.AddCommand(newGet())
// Apply optional overrides to this command.
for _, fn := range cmdOverrides {
fn(cmd)
return cmd
// start create command
var createOverrides []func(
*cobra.Command,
*catalog.CreateOnlineTableRequest,
func newCreate() *cobra.Command {
cmd := &cobra.Command{}
var createReq catalog.CreateOnlineTableRequest
var createJson flags.JsonFlag
// TODO: short flags
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Full three-part (catalog, schema, table) name of the table.`)
// TODO: complex arg: spec
cmd.Use = "create"
cmd.Short = `Create an Online Table.`
cmd.Long = `Create an Online Table.
Create a new Online Table.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
check := root.ExactArgs(0)
return check(cmd, args)
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
response, err := w.OnlineTables.Create(ctx, createReq)
return cmdio.Render(ctx, response)
// Disable completions since they are not applicable.
// Can be overridden by manual implementation in `override.go`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
for _, fn := range createOverrides {
fn(cmd, &createReq)
// start delete command
var deleteOverrides []func(
*catalog.DeleteOnlineTableRequest,
func newDelete() *cobra.Command {
var deleteReq catalog.DeleteOnlineTableRequest
cmd.Use = "delete NAME"
cmd.Short = `Delete an Online Table.`
cmd.Long = `Delete an Online Table.
Delete an online table. Warning: This will delete all the data in the online
table. If the source Delta table was deleted or modified since this Online
Table was created, this will lose the data forever!
Arguments:
NAME: Full three-part (catalog, schema, table) name of the table.`
check := root.ExactArgs(1)
deleteReq.Name = args[0]
err = w.OnlineTables.Delete(ctx, deleteReq)
return nil
for _, fn := range deleteOverrides {
fn(cmd, &deleteReq)
// start get command
var getOverrides []func(
*catalog.GetOnlineTableRequest,
func newGet() *cobra.Command {
var getReq catalog.GetOnlineTableRequest
cmd.Use = "get NAME"
cmd.Short = `Get an Online Table.`
cmd.Long = `Get an Online Table.
Get information about an existing online table and its status.
getReq.Name = args[0]
response, err := w.OnlineTables.Get(ctx, getReq)
for _, fn := range getOverrides {
fn(cmd, &getReq)
// end service OnlineTables