cli icon indicating copy to clipboard operation
cli copied to clipboard

databricks jobs list-runs limit does not work

Open frankivo opened this issue 1 year ago • 8 comments

Describe the issue

I want to get just the latest run, but I seem to fail.

The --help describes limit as follows:

--limit int The number of runs to return.

The api (https://docs.databricks.com/api/workspace/jobs/listruns#limit) mentions limit as follows:

The number of runs to return. This value must be greater than 0 and less than 25. The default value is 20. If a request specifies a limit of 0, the service instead uses the maximum limit.

I wonder why I get more than 20 or even 25 results.

Steps to reproduce the behavior

Please list the steps required to reproduce the issue, for example: databricks jobs list-runs --job-id xxx --limit 1

Expected Behavior

I want to get just the latest job-run when I provide --limit 1

Actual Behavior

Clear and concise description of what actually happened

OS and CLI version

Databricks CLI v0.220.0 on Windows using WSL

Is this a regression?

I'm not sure.

Debug Logs

16:49:35 DEBUG GET /api/2.1/jobs/runs/list?job_id=xxx&limit=1 16:49:35 DEBUG GET /api/2.1/jobs/runs/list?job_id=xxx&limit=1&page_token=CAEQ97q7kfwxIL7F6NfD-wQ= 16:49:35 DEBUG GET /api/2.1/jobs/runs/list?job_id=xxx&limit=1&page_token=CAEQxevk9_sxII6r2p_NIg== [...]

frankivo avatar May 29 '24 14:05 frankivo

Not sure if it helps but I've noticed similar on the cluster events call - limit seems to be used to control how many results are sent in each batch, not to control the number of results total. In the cluster events example it actually only serves to make the command slower. Just never got around to opening an issue for it.

NodeJSmith avatar Jun 04 '24 12:06 NodeJSmith

Interesting... at least the documentation is ambiguous then :)

frankivo avatar Jun 04 '24 12:06 frankivo

Same issue with jobs list on CLI v0.230.0. I'm running on Mac OS. I only want to list, say, 5 jobs but no matter what I specify for --limit I get all the jobs. I have also observed the behavior that the --limit flag seems to be setting the batch / page size for the results. The higher I set it, the faster the jobs list command completes.

btello avatar Oct 09 '24 14:10 btello

Agreed that the documentation on the "limit" keyword is not correct and should be updated to clarify that it is the limit used under the hood for pagination but does not affect the # of returned results.

s4m0r4m4 avatar Dec 09 '24 16:12 s4m0r4m4

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 08 '25 00:02 github-actions[bot]

The documentation needs to be updated - I am relatively certain this limit, in newer versions of the lib, is not a total limit but a limit per page that it uses under the hood. This api will return the total list of jobs, regardless of page size.

Requesting confirmation from the databricks team and an update to the documentation if warranted.

s4m0r4m4 avatar Feb 08 '25 19:02 s4m0r4m4

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 Apr 11 '25 00:04 github-actions[bot]

Bump

s4m0r4m4 avatar Apr 11 '25 01:04 s4m0r4m4

bump. Seeing this on v0.265.0

evanaze avatar Aug 22 '25 19:08 evanaze