Skip to content

Commit 79d6604

Browse files
Add Support for Field Mask in query parameters. (#535)
## What changes are proposed in this pull request? Add Support for Field Mask in query parameters. We are introducing a rich type for FieldMask. This PR ensures that FieldMasks are serialized correctly when used as Query parameters (which is the case for all non batch operations). Support for FieldMask is added as part of generation framework in a separate PR. More information about field mask: https://developers.google.com/workspace/slides/api/guides/field-masks Other Well Known types are not currently supported as query parameters. Tests are being generated, so they are not part of this PR. ## How is this tested? Chicken and egg problem. We have 3 components, all of which are needed to test this: 1. New structures with the new types. 2. Generated tests. 3. The change in this PR. Components 1 and 2 are generated and part of another PR. We cannot test this without those components. But at the same time, those components need this change or the generated tests will fail. I generated locally the SDK with all 3 changes at the same time and run `make test` (diff includes many changes. Releavant changes in HttpPathTest.java): https://github.com/databricks/databricks-sdk-java/pull/536/files#diff-e0a2f237fe2b016080aeb672d5793f68486a7b897c7252480c7c00a76f08796f NO_CHANGELOG=true
1 parent 586a832 commit 79d6604

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

databricks-sdk-java/src/main/java/com/databricks/sdk/core/GrpcTranscodingQueryParamsSerializer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.databricks.sdk.support.QueryParam;
44
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.google.protobuf.FieldMask;
56
import java.lang.reflect.Field;
67
import java.util.*;
78

@@ -118,6 +119,8 @@ private static Map<String, Object> flattenObject(Object o, Boolean onlyAnnotated
118119
|| Iterable.class.isAssignableFrom(type)
119120
|| type.isEnum()) {
120121
result.put(name, value);
122+
} else if (FieldMask.class.isAssignableFrom(type)) {
123+
result.put(name, String.join(",", ((FieldMask) value).getPathsList()));
121124
} else {
122125
// recursively flatten the object
123126
Map<String, Object> flattened = flattenObject(value, false);

0 commit comments

Comments
 (0)