databricks / databricks-sdk-go

Databricks SDK for Go
https://docs.databricks.com/dev-tools/sdk-go.html
Apache License 2.0
46 stars 37 forks source link

[ISSUE] Nullable fields not properly represented in OpenAPI generated models #620

Open ryanaston opened 9 months ago

ryanaston commented 9 months ago

Description While many models properly set the omitempty flag in the json annotation, they do not use pointers, causing default values to populate. This is particularly problematic for ColumnInfo where the presence or absence of a zero-indexed partition_index field indicates whether or not a column is part of the partition structure.

Expected behavior Codegen should support pointers for optional fields.

Additional context Another report related to this issue here: https://github.com/databricks/databricks-sdk-go/issues/516

mgyucht commented 7 months ago

@ryanaston we made a tradeoff in the SDK not to use pointers to increase the usability of the SDK. We've modeled our SDK after Google's Go SDK, which does the same. Optional values that must be sent in a request or that were explicitly set in a response are present in the ForceSendFields field of every generated structure. The value of this field is a string with comma-separated field names that correspond to an explicit zero value in the serialized message. You should be able to check which structure contains PartitionInfo in ForceSendFields to find the appropriate column.