cli icon indicating copy to clipboard operation
cli copied to clipboard

Cannot pass filter arguments to the databricks query-history list command

Open MAJVeld opened this issue 1 year ago • 2 comments

Describe the issue

No filtering capabilities seems to be implemented when using the databricks query-history list command of the CLI despite the help suggesting otherwise.

Steps to reproduce the behavior

Please list the steps required to reproduce the issue, for example:

  1. Run databricks query-history list -h
  2. Check the generated output:
> databricks query-history list -h
List Queries.

  List the history of queries through SQL warehouses.

  **You can filter by user ID, warehouse ID, status, and time range.**

Usage:
  databricks query-history list [flags]

Flags:
  -h, --help                help for list
      --include-metrics     Whether to include metrics about query.
      --max-results int     Limit the number of results returned in one page.
      --page-token string   A token that can be used to get the next page of results.
  1. The documentation suggests that filtering on user ID, warehouse ID, status, and time range are possible, but no flags are available to execute said filtering.

Expected Behavior

Documentation and supported filtering options are in sync.

Actual Behavior

Either no suggestion about the non-existent filtering capabilities is made, or the filtering capabilities are actually implemented

OS and CLI version

Latest available version 0.129.0

Is this a regression?

No

MAJVeld avatar May 16 '24 09:05 MAJVeld

Thanks for raising the issue.

The API docs indeed state this is possible: https://docs.databricks.com/api/workspace/queryhistory/list. What's happening is that because the "filter" object is a nested object, we don't automatically generate flags for the options that are broken out.

If you need to use this API today you could use databricks api get to DIY the right request, until we fix this properly.

pietern avatar May 16 '24 09:05 pietern

@pietern Thanks for the reply. I understand that the functionality is not in place at the moment and that the Databricks REST api must be used directly.

However, until the suggested fix is in place, it may be a good idea to adapt the generated documentation for the command by commenting out line 65 of https://github.com/databricks/cli/blame/main/cmd/workspace/query-history/query-history.go Link to avoid any confusion by the end user.

MAJVeld avatar May 27 '24 08:05 MAJVeld

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

github-actions[bot] avatar Feb 06 '25 00:02 github-actions[bot]