databricks-sdk-go icon indicating copy to clipboard operation
databricks-sdk-go copied to clipboard

Improve semantics for listing methods

Open nfx opened this issue 2 years ago • 6 comments

This PR moves listing requests to an ListXXXInternal entity, which keeps all the low-level pagination request fields, like offset, limit, token, page. Original entity keeps all of the fields, except pagination-related. This allows to mitigate a common confusion, where users supply limit for the iterator and it acting only a result page limit, not the max number of results.

Follow-up Python SDK PR: https://github.com/databricks/databricks-sdk-py/pull/279

nfx avatar Aug 03 '23 16:08 nfx

Is the idea that the limit field in the request is only used for the page size and not the total number of responses? I thought you would just be able to remove https://github.com/databricks/databricks-sdk-go/blob/main/.codegen/api.go.tmpl#L219-L221, then no global limit is enforced and this API behaves the same as in the other SDKs.

Rather than supporting a global limit, we should instead switch to the lazy iterator approach and allow users to pull as many resources as they need.

mgyucht avatar Aug 04 '23 08:08 mgyucht

@mgyucht https://github.com/databricks/databricks-sdk-go/blob/main/.codegen/api.go.tmpl#L219-L221 i think we need to change this to max_results "virtual field", that would do a "global limit". Or we can keep the limit name, but redefine the semantics for when they're used in iterators. It's necessary for things like CLI. e.g. get the latest XX jobs or show the latest XX queries.

nfx avatar Aug 04 '23 13:08 nfx

Once I get around to https://github.com/databricks/databricks-sdk-go/pull/543, users can define their own iterators and filter however they like. IMO I don't think it needs to be built into the Go SDK, and it isn't in any other SDK we publish today.

mgyucht avatar Aug 04 '23 13:08 mgyucht

@mgyucht it's orthogonal to #543 (we should hold on that because of the upcoming language changes - https://github.com/golang/go/issues/61405).

this change is about cross-SDK semantics on removing low-level fields to paginated methods, so it should be merged ;)

nfx avatar Aug 07 '23 08:08 nfx

Codecov Report

Patch coverage: 1.55% and project coverage change: +0.07% :tada:

Comparison is base (a3c5a3c) 17.97% compared to head (b55e389) 18.04%. Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #569      +/-   ##
==========================================
+ Coverage   17.97%   18.04%   +0.07%     
==========================================
  Files          85       85              
  Lines        9805     9990     +185     
==========================================
+ Hits         1762     1803      +41     
- Misses       7889     8030     +141     
- Partials      154      157       +3     
Files Changed Coverage Δ
openapi/code/method.go 35.36% <ø> (+17.62%) :arrow_up:
service/catalog/api.go 0.00% <0.00%> (ø)
service/catalog/impl.go 0.00% <ø> (ø)
service/catalog/model.go 0.00% <ø> (ø)
service/compute/api.go 12.46% <0.00%> (-0.20%) :arrow_down:
service/compute/impl.go 10.74% <ø> (ø)
service/compute/model.go 0.00% <ø> (ø)
service/iam/model.go 0.00% <ø> (ø)
service/jobs/api.go 0.00% <0.00%> (ø)
service/jobs/impl.go 0.00% <ø> (ø)
... and 14 more

... and 1 file with indirect coverage changes

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 10 '23 09:08 codecov-commenter

Can we prepare the changes in the other SDKs at the same time, since we're making changes to the template logic? This change seems good to me, but to minimize clashes with others developing on the SDKs, I want to decrease the wall-clock time that the OpenAPI generator won't work with the other SDKs.

mgyucht avatar Aug 10 '23 14:08 mgyucht