databricks / cli

Databricks CLI
Other
147 stars 55 forks source link

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

Open MAJVeld opened 6 months ago

MAJVeld commented 6 months ago

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

pietern commented 6 months ago

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.

MAJVeld commented 5 months ago

@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.