Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query param serialization for requests with enums #140

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Aug 19, 2023

Changes

Query parameters are determined reflectively from request classes by scanning for fields with a QueryParam annotation. Serialization of query parameters is recursive in order to support complex types like the filter structures used for listing in the SQL query history service. This PR makes the following changes:

  1. Terminate recursion when the request field is an enum.
  2. When iterating through the request object's fields, skip any fields not annotated with QueryParam (but recursively, all fields do need to be serialized).
  3. Rename the inner class from HeaderEntry to QueryParamPair (it represents query param pairs, not header entries).

Tests

Test for this change is dependent on other testing refactors that will be merged as part of #139.

@mgyucht mgyucht marked this pull request as ready for review August 23, 2023 08:22
@mgyucht mgyucht requested a review from tanmay-db August 23, 2023 08:22
@mgyucht mgyucht changed the title [WIP] Fix query param serialization for requests with enums Fix query param serialization for requests with enums Aug 23, 2023
@mgyucht mgyucht enabled auto-merge August 23, 2023 17:41
@@ -103,24 +97,30 @@ private static String getFieldName(Field f) {
}
}

private static Map<String, Object> flattenObject(Object o) {
private static Map<String, Object> flattenObject(Object o, Boolean onlyAnnotatedFields) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the test is dependent on another PR, should we add a unit tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have... but the other PR should be merged in the next day or two, so I think we can deal with that.

@mgyucht mgyucht added this pull request to the merge queue Aug 24, 2023
Merged via the queue into main with commit d716538 Aug 24, 2023
9 checks passed
@mgyucht mgyucht deleted the fix-query-param-serialization branch August 24, 2023 11:51
mgyucht added a commit that referenced this pull request Aug 29, 2023
* Added support for propagating Request Headers through API Client ([#135](#135)).
* Added support for InputStream for streaming request and response bodies ([#138](#138)).
* Fixed query param serialization for requests with enums ([#140](#140)).

Breaking API Changes:
 * Changed `list()` method for `accountClient.storageCredentials()` service to return `com.databricks.sdk.service.catalog.StorageCredentialInfoList` class.
 * Removed `workspaceClient.securableTags()` service and all related classes.
 * Removed `workspaceClient.subentityTags()` service and all related classes.
 * Renamed `provisioningState` field for `com.databricks.sdk.service.catalog.ConnectionInfo` to `provisioningInfo`.
 * Removed `instancePoolFleetAttributes` field for `com.databricks.sdk.service.compute.CreateInstancePool`.
 * Removed `instancePoolFleetAttributes` field for `com.databricks.sdk.service.compute.EditInstancePool`.
 * Removed `com.databricks.sdk.service.compute.FleetLaunchTemplateOverride` class.
 * Removed `com.databricks.sdk.service.compute.FleetOnDemandOption` class.
 * Removed `com.databricks.sdk.service.compute.FleetOnDemandOptionAllocationStrategy` class.
 * Removed `com.databricks.sdk.service.compute.FleetSpotOption` class.
 * Removed `com.databricks.sdk.service.compute.FleetSpotOptionAllocationStrategy` class.
 * Removed `instancePoolFleetAttributes` field for `com.databricks.sdk.service.compute.GetInstancePool`.
 * Removed `instancePoolFleetAttributes` field for `com.databricks.sdk.service.compute.InstancePoolAndStats`.
 * Removed `com.databricks.sdk.service.compute.InstancePoolFleetAttributes` class.
 * Changed `getByName()` method for `workspaceClient.experiments()` service to return `com.databricks.sdk.service.ml.GetExperimentResponse` class.
 * Changed `getExperiment()` method for `workspaceClient.experiments()` service to return `com.databricks.sdk.service.ml.GetExperimentResponse` class.
 * Renamed `com.databricks.sdk.service.ml.GetExperimentByNameResponse` class to `com.databricks.sdk.service.ml.GetExperimentResponse`.

API Changes:

 * Added `workspaceClient.modelVersions()` service.
 * Added `workspaceClient.registeredModels()` service.
 * Added `browseOnly` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Added `fullName` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Added `provisioningInfo` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Added `securableKind` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Added `securableType` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Added `options` field for `com.databricks.sdk.service.catalog.CreateCatalog`.
 * Added `options` field for `com.databricks.sdk.service.catalog.UpdateCatalog`.
 * Added `com.databricks.sdk.service.catalog.CatalogInfoSecurableKind` class.
 * Added `com.databricks.sdk.service.catalog.CreateRegisteredModelRequest` class.
 * Added `com.databricks.sdk.service.catalog.DeleteAliasRequest` class.
 * Added `com.databricks.sdk.service.catalog.DeleteModelVersionRequest` class.
 * Added `com.databricks.sdk.service.catalog.DeleteRegisteredModelRequest` class.
 * Added `com.databricks.sdk.service.catalog.GetByAliasRequest` class.
 * Added `com.databricks.sdk.service.catalog.GetModelVersionRequest` class.
 * Added `com.databricks.sdk.service.catalog.GetRegisteredModelRequest` class.
 * Added `com.databricks.sdk.service.catalog.ListModelVersionsRequest` class.
 * Added `com.databricks.sdk.service.catalog.ListModelVersionsResponse` class.
 * Added `com.databricks.sdk.service.catalog.ListRegisteredModelsRequest` class.
 * Added `com.databricks.sdk.service.catalog.ListRegisteredModelsResponse` class.
 * Added `com.databricks.sdk.service.catalog.ModelVersionInfo` class.
 * Added `com.databricks.sdk.service.catalog.ModelVersionInfoStatus` class.
 * Added `com.databricks.sdk.service.catalog.ProvisioningInfo` class.
 * Added `com.databricks.sdk.service.catalog.ProvisioningInfoState` class.
 * Added `com.databricks.sdk.service.catalog.RegisteredModelAlias` class.
 * Added `com.databricks.sdk.service.catalog.RegisteredModelInfo` class.
 * Added `com.databricks.sdk.service.catalog.SetRegisteredModelAliasRequest` class.
 * Added `com.databricks.sdk.service.catalog.UpdateModelVersionRequest` class.
 * Added `com.databricks.sdk.service.catalog.UpdateRegisteredModelRequest` class.
 * Added `volumes` field for `com.databricks.sdk.service.compute.InitScriptInfo`.
 * Added `com.databricks.sdk.service.compute.VolumesStorageInfo` class.
 * Added `workspaceClient.files()` service.
 * Added `com.databricks.sdk.service.files.DeleteFileRequest` class.
 * Added `com.databricks.sdk.service.files.DownloadRequest` class.
 * Added `com.databricks.sdk.service.files.DownloadResponse` class.
 * Added `com.databricks.sdk.service.files.UploadRequest` class.
 * Added `customTags` field for `com.databricks.sdk.service.provisioning.CreateWorkspaceRequest`.
 * Added `customTags` field for `com.databricks.sdk.service.provisioning.UpdateWorkspaceRequest`.
 * Added `customTags` field for `com.databricks.sdk.service.provisioning.Workspace`.
 * Added `com.databricks.sdk.service.provisioning.CustomTags` class.
 * Added `parameters` field for `com.databricks.sdk.service.sql.ExecuteStatementRequest`.
 * Added `rowLimit` field for `com.databricks.sdk.service.sql.ExecuteStatementRequest`.
 * Added `com.databricks.sdk.service.sql.StatementParameterListItem` class.

OpenAPI SHA: 5d0ccbb790d341eae8e85321a685a9e9e2d5bf24, Date: 2023-08-29
@mgyucht mgyucht mentioned this pull request Aug 29, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 29, 2023
* Added support for propagating Request Headers through API Client
([#135](#135)).
* Added support for InputStream for streaming request and response
bodies
([#138](#138)).
* Fixed query param serialization for requests with enums
([#140](#140)).

Breaking API Changes:
* Changed `list()` method for `accountClient.storageCredentials()`
service to return
`com.databricks.sdk.service.catalog.StorageCredentialInfoList` class.
* Removed `workspaceClient.securableTags()` service and all related
classes.
* Removed `workspaceClient.subentityTags()` service and all related
classes.
* Renamed `provisioningState` field for
`com.databricks.sdk.service.catalog.ConnectionInfo` to
`provisioningInfo`.
* Removed `instancePoolFleetAttributes` field for
`com.databricks.sdk.service.compute.CreateInstancePool`.
* Removed `instancePoolFleetAttributes` field for
`com.databricks.sdk.service.compute.EditInstancePool`.
* Removed
`com.databricks.sdk.service.compute.FleetLaunchTemplateOverride` class.
* Removed `com.databricks.sdk.service.compute.FleetOnDemandOption`
class.
* Removed
`com.databricks.sdk.service.compute.FleetOnDemandOptionAllocationStrategy`
class.
 * Removed `com.databricks.sdk.service.compute.FleetSpotOption` class.
* Removed
`com.databricks.sdk.service.compute.FleetSpotOptionAllocationStrategy`
class.
* Removed `instancePoolFleetAttributes` field for
`com.databricks.sdk.service.compute.GetInstancePool`.
* Removed `instancePoolFleetAttributes` field for
`com.databricks.sdk.service.compute.InstancePoolAndStats`.
* Removed
`com.databricks.sdk.service.compute.InstancePoolFleetAttributes` class.
* Changed `getByName()` method for `workspaceClient.experiments()`
service to return `com.databricks.sdk.service.ml.GetExperimentResponse`
class.
* Changed `getExperiment()` method for `workspaceClient.experiments()`
service to return `com.databricks.sdk.service.ml.GetExperimentResponse`
class.
* Renamed `com.databricks.sdk.service.ml.GetExperimentByNameResponse`
class to `com.databricks.sdk.service.ml.GetExperimentResponse`.

API Changes:

 * Added `workspaceClient.modelVersions()` service.
 * Added `workspaceClient.registeredModels()` service.
* Added `browseOnly` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Added `fullName` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Added `provisioningInfo` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Added `securableKind` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Added `securableType` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Added `options` field for
`com.databricks.sdk.service.catalog.CreateCatalog`.
* Added `options` field for
`com.databricks.sdk.service.catalog.UpdateCatalog`.
* Added `com.databricks.sdk.service.catalog.CatalogInfoSecurableKind`
class.
* Added
`com.databricks.sdk.service.catalog.CreateRegisteredModelRequest` class.
 * Added `com.databricks.sdk.service.catalog.DeleteAliasRequest` class.
* Added `com.databricks.sdk.service.catalog.DeleteModelVersionRequest`
class.
* Added
`com.databricks.sdk.service.catalog.DeleteRegisteredModelRequest` class.
 * Added `com.databricks.sdk.service.catalog.GetByAliasRequest` class.
* Added `com.databricks.sdk.service.catalog.GetModelVersionRequest`
class.
* Added `com.databricks.sdk.service.catalog.GetRegisteredModelRequest`
class.
* Added `com.databricks.sdk.service.catalog.ListModelVersionsRequest`
class.
* Added `com.databricks.sdk.service.catalog.ListModelVersionsResponse`
class.
* Added `com.databricks.sdk.service.catalog.ListRegisteredModelsRequest`
class.
* Added
`com.databricks.sdk.service.catalog.ListRegisteredModelsResponse` class.
 * Added `com.databricks.sdk.service.catalog.ModelVersionInfo` class.
* Added `com.databricks.sdk.service.catalog.ModelVersionInfoStatus`
class.
 * Added `com.databricks.sdk.service.catalog.ProvisioningInfo` class.
* Added `com.databricks.sdk.service.catalog.ProvisioningInfoState`
class.
* Added `com.databricks.sdk.service.catalog.RegisteredModelAlias` class.
 * Added `com.databricks.sdk.service.catalog.RegisteredModelInfo` class.
* Added
`com.databricks.sdk.service.catalog.SetRegisteredModelAliasRequest`
class.
* Added `com.databricks.sdk.service.catalog.UpdateModelVersionRequest`
class.
* Added
`com.databricks.sdk.service.catalog.UpdateRegisteredModelRequest` class.
* Added `volumes` field for
`com.databricks.sdk.service.compute.InitScriptInfo`.
 * Added `com.databricks.sdk.service.compute.VolumesStorageInfo` class.
 * Added `workspaceClient.files()` service.
 * Added `com.databricks.sdk.service.files.DeleteFileRequest` class.
 * Added `com.databricks.sdk.service.files.DownloadRequest` class.
 * Added `com.databricks.sdk.service.files.DownloadResponse` class.
 * Added `com.databricks.sdk.service.files.UploadRequest` class.
* Added `customTags` field for
`com.databricks.sdk.service.provisioning.CreateWorkspaceRequest`.
* Added `customTags` field for
`com.databricks.sdk.service.provisioning.UpdateWorkspaceRequest`.
* Added `customTags` field for
`com.databricks.sdk.service.provisioning.Workspace`.
 * Added `com.databricks.sdk.service.provisioning.CustomTags` class.
* Added `parameters` field for
`com.databricks.sdk.service.sql.ExecuteStatementRequest`.
* Added `rowLimit` field for
`com.databricks.sdk.service.sql.ExecuteStatementRequest`.
* Added `com.databricks.sdk.service.sql.StatementParameterListItem`
class.

OpenAPI SHA: 5d0ccbb790d341eae8e85321a685a9e9e2d5bf24, Date: 2023-08-29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants