-
Notifications
You must be signed in to change notification settings - Fork 25
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
Handle nested query parameters in ApiClient.withQuery #125
Conversation
private static final List<Class<?>> primitiveTypes = | ||
Arrays.asList( | ||
boolean.class, | ||
Boolean.class, | ||
byte.class, | ||
Byte.class, | ||
char.class, | ||
Character.class, | ||
short.class, | ||
Short.class, | ||
int.class, | ||
Integer.class, | ||
long.class, | ||
Long.class, | ||
float.class, | ||
Float.class, | ||
double.class, | ||
Double.class, | ||
String.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably reuse this in future, it might be good to have this in a separate file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to reuse it, we can make it public at some point. It's hard to figure out what class/file this would exist in that would be useful in other contexts, so I would rather leave it as is until we have two or three other things that it makes sense to group this with.
List<String> values = query.get(key); | ||
if (values == null) { | ||
values = new ArrayList<>(); | ||
} | ||
values.add(value); | ||
query.put(key, values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle the use case for when key exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the key exists, values is not null, so we just skip the if block. Note that I've refactored this, as the put at the end is only needed in the case that values is null.
if (currentPage == null) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious -- why wasn't this required before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a separate bugfix, but I think that the query history API does not include the "results" field at all if there are no results. This is handled in flipNextPage line 63, but not in hasNext().
* Handle nested query parameters in ApiClient.withQuery ([#125](#125)). This fixes issues with filters when listing query history. API Changes: * Changed `create()` method for `accountClient.metastoreAssignments()` service to no longer return `com.databricks.sdk.service.catalog.CreateMetastoreAssignmentsResponseItemList` class. * Added `connectionName` field for `com.databricks.sdk.service.catalog.CreateCatalog`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.CreateExternalLocation`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.CreateExternalLocation`. * Removed `com.databricks.sdk.service.catalog.CreateMetastoreAssignmentsResponseItem` class. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.ExternalLocationInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.ExternalLocationInfo`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.TableInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.TableInfo`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.VolumeInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.VolumeInfo`. * Added `com.databricks.sdk.service.catalog.EncryptionDetails` class. * Added `com.databricks.sdk.service.catalog.SseEncryptionDetails` class. * Added `com.databricks.sdk.service.catalog.SseEncryptionDetailsAlgorithm` class. * Added `accountClient.networkPolicy()` service. * Added `com.databricks.sdk.service.settings.AccountNetworkPolicyMessage` class. * Added `com.databricks.sdk.service.settings.DeleteAccountNetworkPolicyRequest` class. * Added `com.databricks.sdk.service.settings.DeleteAccountNetworkPolicyResponse` class. * Added `com.databricks.sdk.service.settings.ReadAccountNetworkPolicyRequest` class. * Added `com.databricks.sdk.service.settings.UpdateAccountNetworkPolicyRequest` class. OpenAPI SHA: fbdd0fa3e83fed2c798a58d376529bdb1285b915, Date: 2023-07-26
* Handled nested query parameters in ApiClient.withQuery ([#125](#125)). This fixes issues with filters when listing query history. API Changes: * Changed `create()` method for `accountClient.metastoreAssignments()` service to no longer return `com.databricks.sdk.service.catalog.CreateMetastoreAssignmentsResponseItemList` class. * Added `connectionName` field for `com.databricks.sdk.service.catalog.CreateCatalog`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.CreateExternalLocation`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.CreateExternalLocation`. * Removed `com.databricks.sdk.service.catalog.CreateMetastoreAssignmentsResponseItem` class. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.ExternalLocationInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.ExternalLocationInfo`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.TableInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.TableInfo`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * Added `accessPoint` field for `com.databricks.sdk.service.catalog.VolumeInfo`. * Added `encryptionDetails` field for `com.databricks.sdk.service.catalog.VolumeInfo`. * Added `com.databricks.sdk.service.catalog.EncryptionDetails` class. * Added `com.databricks.sdk.service.catalog.SseEncryptionDetails` class. * Added `com.databricks.sdk.service.catalog.SseEncryptionDetailsAlgorithm` class. * Added `accountClient.networkPolicy()` service. * Added `com.databricks.sdk.service.settings.AccountNetworkPolicyMessage` class. * Added `com.databricks.sdk.service.settings.DeleteAccountNetworkPolicyRequest` class. * Added `com.databricks.sdk.service.settings.DeleteAccountNetworkPolicyResponse` class. * Added `com.databricks.sdk.service.settings.ReadAccountNetworkPolicyRequest` class. * Added `com.databricks.sdk.service.settings.UpdateAccountNetworkPolicyRequest` class. OpenAPI SHA: fbdd0fa3e83fed2c798a58d376529bdb1285b915, Date: 2023-07-26 --------- Co-authored-by: Tanmay Rustagi <88379306+tanmay-db@users.noreply.github.com>
Changes
The Query History list API filter_by query parameter is modeled by a dictionary, rather than a primitive type, defining the allowed filters including query_start_time_range, statuses, user_ids, and warehouse_ids. To be compatible with gRPC transcoding, query parameters modeled by message types as opposed to primitives need to be separated into one query parameter per nested field, where the key is the path to that query parameter. For example:
becomes
For this to be compatible with the requests library we use today, we need to recursively compute the path of each field in the request object that is annotated with the
QueryParam
annotation, then serialize the value according to Jackson.As part of this, I've also generalized the
Request
class to support repeated query parameter values for lists (see the added integration test).This resolves one of the problems from databricks/databricks-sdk-py#99. The issue with the conflict between filter_by and next_page_token will be resolved by the backend service.
Tests
Added an integration test for SQL Query History API.