From ff5eed59233c94f2cba0af9d751c15a72dd04c41 Mon Sep 17 00:00:00 2001 From: Chenyue Ma Date: Thu, 24 Sep 2026 22:50:04 +0000 Subject: [PATCH 1/4] Align pipelines show preview with PRD --- .nextchanges/cli/pipelines-show-default.md | 1 + acceptance/pipelines/show/basic/output.txt | 23 ++++++++++++++++--- acceptance/pipelines/show/basic/test.toml | 2 +- acceptance/pipelines/show/help/output.txt | 2 +- .../pipelines/show/rendering/output.txt | 1 + cmd/pipelines/show.go | 13 +++++++++-- 6 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 .nextchanges/cli/pipelines-show-default.md diff --git a/.nextchanges/cli/pipelines-show-default.md b/.nextchanges/cli/pipelines-show-default.md new file mode 100644 index 00000000000..8b9cf2cf18d --- /dev/null +++ b/.nextchanges/cli/pipelines-show-default.md @@ -0,0 +1 @@ +* Align `databricks pipelines show` with the SDP CLI preview behavior by returning five rows by default and suggesting `--limit` when more rows may be available. diff --git a/acceptance/pipelines/show/basic/output.txt b/acceptance/pipelines/show/basic/output.txt index 87fe70aeeee..bf7d94ac03f 100644 --- a/acceptance/pipelines/show/basic/output.txt +++ b/acceptance/pipelines/show/basic/output.txt @@ -2,12 +2,17 @@ === table output >>> [CLI] pipelines show main.default.people +Table: main.default.people id name -- ----- 1 alice 2 bob +3 carol +4 dave +5 eve -2 rows +5 rows +Use --limit to preview more rows. === json output @@ -20,6 +25,18 @@ id name { "id": "2", "name": "bob" + }, + { + "id": "3", + "name": "carol" + }, + { + "id": "4", + "name": "dave" + }, + { + "id": "5", + "name": "eve" } ] @@ -38,7 +55,7 @@ Error: invalid table name "people": expected catalog.schema.table (Unity Catalog "disposition": "INLINE", "format": "JSON_ARRAY", "on_wait_timeout": "CONTINUE", - "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 10", + "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 5", "wait_timeout": "10s", "warehouse_id": "wh-test" } @@ -50,7 +67,7 @@ Error: invalid table name "people": expected catalog.schema.table (Unity Catalog "disposition": "INLINE", "format": "JSON_ARRAY", "on_wait_timeout": "CONTINUE", - "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 10", + "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 5", "wait_timeout": "10s", "warehouse_id": "wh-test" } diff --git a/acceptance/pipelines/show/basic/test.toml b/acceptance/pipelines/show/basic/test.toml index 402303373c1..853d4809d27 100644 --- a/acceptance/pipelines/show/basic/test.toml +++ b/acceptance/pipelines/show/basic/test.toml @@ -14,6 +14,6 @@ Response.Body = ''' "statement_id": "s1", "status": {"state": "SUCCEEDED"}, "manifest": {"schema": {"columns": [{"name": "id"}, {"name": "name"}]}, "total_chunk_count": 1}, - "result": {"data_array": [["1", "alice"], ["2", "bob"]]} + "result": {"data_array": [["1", "alice"], ["2", "bob"], ["3", "carol"], ["4", "dave"], ["5", "eve"]]} } ''' diff --git a/acceptance/pipelines/show/help/output.txt b/acceptance/pipelines/show/help/output.txt index 67a94f1bdb1..a18e02771c6 100644 --- a/acceptance/pipelines/show/help/output.txt +++ b/acceptance/pipelines/show/help/output.txt @@ -11,7 +11,7 @@ Usage: Flags: -h, --help help for show - -n, --limit int Maximum number of rows to fetch. (default 10) + -n, --limit int Maximum number of rows to fetch. (default 5) --warehouse-id string SQL warehouse to run the query on. Defaults to DATABRICKS_WAREHOUSE_ID or a workspace default. Global Flags: diff --git a/acceptance/pipelines/show/rendering/output.txt b/acceptance/pipelines/show/rendering/output.txt index 499332abbba..9f981acd458 100644 --- a/acceptance/pipelines/show/rendering/output.txt +++ b/acceptance/pipelines/show/rendering/output.txt @@ -2,6 +2,7 @@ === table output: long note truncated, ragged row blank cell >>> [CLI] pipelines show main.default.people +Table: main.default.people name id note ----- -- ---------------------------------------- alice 1 this is a very long note value that e... diff --git a/cmd/pipelines/show.go b/cmd/pipelines/show.go index 0e115e0508d..04a46b7c5b9 100644 --- a/cmd/pipelines/show.go +++ b/cmd/pipelines/show.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/cobra" ) -const defaultLimit = 10 +const defaultLimit = 5 func showCommand() *cobra.Command { var warehouseID string @@ -64,7 +64,16 @@ schema.table (legacy Hive metastore).`, return err } - return render(ctx, cmd, result.Columns, result.Rows) + if root.OutputType(cmd) == flags.OutputText { + fmt.Fprintf(cmd.OutOrStdout(), "Table: %s\n", args[0]) + } + if err := render(ctx, cmd, result.Columns, result.Rows); err != nil { + return err + } + if root.OutputType(cmd) == flags.OutputText && !cmd.Flags().Changed("limit") && len(result.Rows) == limit { + fmt.Fprintln(cmd.OutOrStdout(), "Use --limit to preview more rows.") + } + return nil }, } From 5537c3675b62414ccb80bcfafae6d57286d893f9 Mon Sep 17 00:00:00 2001 From: Chenyue Ma Date: Mon, 28 Sep 2026 21:52:24 +0000 Subject: [PATCH 2/4] Extend pipelines history command --- .nextchanges/cli/pipelines-public-api.md | 1 + .nextchanges/cli/pipelines-show-default.md | 1 - .../pipelines/history/basic/out.test.toml | 2 + acceptance/pipelines/history/basic/output.txt | 59 +++++++++++++++++++ acceptance/pipelines/history/basic/script | 8 +++ acceptance/pipelines/history/basic/test.toml | 16 +++++ cmd/pipelines/history.go | 52 ++++++++++------ 7 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 .nextchanges/cli/pipelines-public-api.md delete mode 100644 .nextchanges/cli/pipelines-show-default.md create mode 100644 acceptance/pipelines/history/basic/out.test.toml create mode 100644 acceptance/pipelines/history/basic/output.txt create mode 100644 acceptance/pipelines/history/basic/script create mode 100644 acceptance/pipelines/history/basic/test.toml diff --git a/.nextchanges/cli/pipelines-public-api.md b/.nextchanges/cli/pipelines-public-api.md new file mode 100644 index 00000000000..900ada68547 --- /dev/null +++ b/.nextchanges/cli/pipelines-public-api.md @@ -0,0 +1 @@ +* Show table names and default to 5 rows in `pipelines show`, and support pipeline IDs in `pipelines history`. ([#6871](https://github.com/databricks/cli/pull/6871)) diff --git a/.nextchanges/cli/pipelines-show-default.md b/.nextchanges/cli/pipelines-show-default.md deleted file mode 100644 index 8b9cf2cf18d..00000000000 --- a/.nextchanges/cli/pipelines-show-default.md +++ /dev/null @@ -1 +0,0 @@ -* Align `databricks pipelines show` with the SDP CLI preview behavior by returning five rows by default and suggesting `--limit` when more rows may be available. diff --git a/acceptance/pipelines/history/basic/out.test.toml b/acceptance/pipelines/history/basic/out.test.toml new file mode 100644 index 00000000000..0938e678987 --- /dev/null +++ b/acceptance/pipelines/history/basic/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] diff --git a/acceptance/pipelines/history/basic/output.txt b/acceptance/pipelines/history/basic/output.txt new file mode 100644 index 00000000000..b6b5dc0b39e --- /dev/null +++ b/acceptance/pipelines/history/basic/output.txt @@ -0,0 +1,59 @@ + +=== default history by pipeline id + +>>> [CLI] pipelines history [UUID] +Updates Summary for pipeline [UUID]: +Update ID: update-3 + State: COMPLETED + Creation Time: [TIMESTAMP] + Full Refresh: false + Validate Only: false +Update ID: update-2 + State: FAILED + Creation Time: [TIMESTAMP] + Full Refresh: false + Validate Only: true +Update ID: update-1 + State: CANCELED + Creation Time: [TIMESTAMP] + Full Refresh: false + Validate Only: false + +=== json output + +>>> [CLI] pipelines history [UUID] --output json +{ + "Key": "[UUID]", + "Updates": [ + { + "creation_time": [NUMID], + "state": "COMPLETED", + "update_id": "update-3", + "validate_only": false + }, + { + "creation_time": [NUMID], + "state": "FAILED", + "update_id": "update-2", + "validate_only": true + }, + { + "creation_time": [NUMID], + "state": "CANCELED", + "update_id": "update-1", + "validate_only": false + } + ] +} + +=== wire request uses pipeline id + +>>> print_requests.py //api/2.0/pipelines/[UUID]/updates --get +{ + "method": "GET", + "path": "/api/2.0/pipelines/[UUID]/updates" +} +{ + "method": "GET", + "path": "/api/2.0/pipelines/[UUID]/updates" +} diff --git a/acceptance/pipelines/history/basic/script b/acceptance/pipelines/history/basic/script new file mode 100644 index 00000000000..42fb9e14eb3 --- /dev/null +++ b/acceptance/pipelines/history/basic/script @@ -0,0 +1,8 @@ +title "default history by pipeline id\n" +trace $CLI pipelines history 3fb8e5a1-0d2c-4a6b-9f1e-2c7d8e9f0a1b + +title "json output\n" +trace $CLI pipelines history 3fb8e5a1-0d2c-4a6b-9f1e-2c7d8e9f0a1b --output json + +title "wire request uses pipeline id\n" +trace print_requests.py //api/2.0/pipelines/3fb8e5a1-0d2c-4a6b-9f1e-2c7d8e9f0a1b/updates --get diff --git a/acceptance/pipelines/history/basic/test.toml b/acceptance/pipelines/history/basic/test.toml new file mode 100644 index 00000000000..3f23481ca91 --- /dev/null +++ b/acceptance/pipelines/history/basic/test.toml @@ -0,0 +1,16 @@ +Cloud = false + +EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] +RecordRequests = true + +[[Server]] +Pattern = "GET /api/2.0/pipelines/{pipeline_id}/updates" +Response.Body = ''' +{ + "updates": [ + {"update_id": "update-3", "state": "COMPLETED", "creation_time": 1640995200000, "validate_only": false}, + {"update_id": "update-2", "state": "FAILED", "creation_time": 1640908800000, "validate_only": true}, + {"update_id": "update-1", "state": "CANCELED", "creation_time": 1640822400000, "validate_only": false} + ] +} +''' diff --git a/cmd/pipelines/history.go b/cmd/pipelines/history.go index 6c30d1e72bd..e0c49222402 100644 --- a/cmd/pipelines/history.go +++ b/cmd/pipelines/history.go @@ -2,21 +2,26 @@ package pipelines import ( "fmt" + "regexp" "github.com/databricks/cli/cmd/bundle/utils" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdgroup" "github.com/databricks/cli/libs/cmdio" + databricks "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/spf13/cobra" ) +var pipelineIDRegex = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`) + func historyCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "history [flags] [KEY]", + Use: "history [flags] [KEY|PIPELINE_ID]", Args: root.MaximumNArgs(1), Short: "Retrieve past runs for a pipeline", - Long: `Retrieve past runs for a pipeline identified by KEY, the unique name of the pipeline as defined in its YAML file.`, + Long: `Retrieve past runs for a pipeline identified by KEY, the unique name of the pipeline as defined in its YAML file, or by PIPELINE_ID, the unique identifier of the pipeline.`, } var startTimeStr string @@ -34,25 +39,36 @@ func historyCommand() *cobra.Command { wrappedCmd.AddFlagGroup(historyGroup) cmd.RunE = func(cmd *cobra.Command, args []string) error { - b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{ - InitIDs: true, - }) - if err != nil { - return err - } - ctx := cmd.Context() + var key, pipelineId string + var w *databricks.WorkspaceClient + if len(args) == 1 && pipelineIDRegex.MatchString(args[0]) { + if err := root.MustWorkspaceClient(cmd, args); err != nil { + return err + } + pipelineId = args[0] + key = pipelineId + w = cmdctx.WorkspaceClient(cmd.Context()) + } else { + b, err := utils.ProcessBundle(cmd, utils.ProcessOptions{ + InitIDs: true, + }) + if err != nil { + return err + } + ctx := cmd.Context() - key, err := resolvePipelineArgument(ctx, b, args) - if err != nil { - return err - } + key, err = resolvePipelineArgument(ctx, b, args) + if err != nil { + return err + } - pipelineId, err := resolvePipelineIdFromKey(ctx, b, key) - if err != nil { - return err + pipelineId, err = resolvePipelineIdFromKey(ctx, b, key) + if err != nil { + return err + } + w = b.WorkspaceClient(ctx) } - - w := b.WorkspaceClient(ctx) + ctx := cmd.Context() startTimePtr, err := parseTimeToUnixMillis(startTimeStr) if err != nil { From 60232b120a7e8982d0f0ae8e9779297880312482 Mon Sep 17 00:00:00 2001 From: Chenyue Ma Date: Thu, 8 Oct 2026 17:46:14 +0000 Subject: [PATCH 3/4] Keep pipelines show default limit at 10 --- acceptance/pipelines/show/basic/output.txt | 22 +++------------------- acceptance/pipelines/show/basic/test.toml | 2 +- acceptance/pipelines/show/help/output.txt | 2 +- cmd/pipelines/show.go | 2 +- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/acceptance/pipelines/show/basic/output.txt b/acceptance/pipelines/show/basic/output.txt index bf7d94ac03f..bb981cb69c2 100644 --- a/acceptance/pipelines/show/basic/output.txt +++ b/acceptance/pipelines/show/basic/output.txt @@ -7,12 +7,8 @@ id name -- ----- 1 alice 2 bob -3 carol -4 dave -5 eve -5 rows -Use --limit to preview more rows. +2 rows === json output @@ -25,18 +21,6 @@ Use --limit to preview more rows. { "id": "2", "name": "bob" - }, - { - "id": "3", - "name": "carol" - }, - { - "id": "4", - "name": "dave" - }, - { - "id": "5", - "name": "eve" } ] @@ -55,7 +39,7 @@ Error: invalid table name "people": expected catalog.schema.table (Unity Catalog "disposition": "INLINE", "format": "JSON_ARRAY", "on_wait_timeout": "CONTINUE", - "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 5", + "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 10", "wait_timeout": "10s", "warehouse_id": "wh-test" } @@ -67,7 +51,7 @@ Error: invalid table name "people": expected catalog.schema.table (Unity Catalog "disposition": "INLINE", "format": "JSON_ARRAY", "on_wait_timeout": "CONTINUE", - "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 5", + "statement": "SELECT * FROM `main`.`default`.`people` LIMIT 10", "wait_timeout": "10s", "warehouse_id": "wh-test" } diff --git a/acceptance/pipelines/show/basic/test.toml b/acceptance/pipelines/show/basic/test.toml index 853d4809d27..402303373c1 100644 --- a/acceptance/pipelines/show/basic/test.toml +++ b/acceptance/pipelines/show/basic/test.toml @@ -14,6 +14,6 @@ Response.Body = ''' "statement_id": "s1", "status": {"state": "SUCCEEDED"}, "manifest": {"schema": {"columns": [{"name": "id"}, {"name": "name"}]}, "total_chunk_count": 1}, - "result": {"data_array": [["1", "alice"], ["2", "bob"], ["3", "carol"], ["4", "dave"], ["5", "eve"]]} + "result": {"data_array": [["1", "alice"], ["2", "bob"]]} } ''' diff --git a/acceptance/pipelines/show/help/output.txt b/acceptance/pipelines/show/help/output.txt index a18e02771c6..67a94f1bdb1 100644 --- a/acceptance/pipelines/show/help/output.txt +++ b/acceptance/pipelines/show/help/output.txt @@ -11,7 +11,7 @@ Usage: Flags: -h, --help help for show - -n, --limit int Maximum number of rows to fetch. (default 5) + -n, --limit int Maximum number of rows to fetch. (default 10) --warehouse-id string SQL warehouse to run the query on. Defaults to DATABRICKS_WAREHOUSE_ID or a workspace default. Global Flags: diff --git a/cmd/pipelines/show.go b/cmd/pipelines/show.go index 04a46b7c5b9..b19880d6896 100644 --- a/cmd/pipelines/show.go +++ b/cmd/pipelines/show.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/cobra" ) -const defaultLimit = 5 +const defaultLimit = 10 func showCommand() *cobra.Command { var warehouseID string From 18bc08643f32ec1ba2bb5cb35ef1a9857e7e5708 Mon Sep 17 00:00:00 2001 From: Chenyue Ma Date: Thu, 8 Oct 2026 18:33:23 +0000 Subject: [PATCH 4/4] Update pipelines public API release note --- .nextchanges/cli/pipelines-public-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/cli/pipelines-public-api.md b/.nextchanges/cli/pipelines-public-api.md index 900ada68547..d48928f4a91 100644 --- a/.nextchanges/cli/pipelines-public-api.md +++ b/.nextchanges/cli/pipelines-public-api.md @@ -1 +1 @@ -* Show table names and default to 5 rows in `pipelines show`, and support pipeline IDs in `pipelines history`. ([#6871](https://github.com/databricks/cli/pull/6871)) +* Show table names and a hint for previewing more rows in `pipelines show`, and support pipeline IDs in `pipelines history`. ([#6871](https://github.com/databricks/cli/pull/6871))