Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Mar 13, 2024

This introduces an explicit JSON parser for ConfigResponse as a preparation step for the capabilities that are being introduced by #9940.

Currently, ConfigResponse is relying on reflection to properly do JSON <--> ConfigResponse.
Having an explicit JSON parser has the advantage that the underlying capabilities can be parsed in a way that gives us more flexiblity and allows to be fully forward/backward compatible when new capabilities are being added.

@github-actions github-actions bot added the core label Mar 13, 2024

gen.writeStartObject();

JsonUtil.writeStringMap(DEFAULTS, response.defaults(), gen);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

existing tests in TestConfigResponse expect the maps to be always written (even if empty), so I omitted having a isEmpty() check

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just change this to not send back the key in the response in the value is null (makes for a cleaner response? I don't really think that's a behavior change since in the end a client needs to check that the value is not null.

Copy link
Contributor

Choose a reason for hiding this comment

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

NVM these two fields are spec'd out so it seems like servers should always send it even though it may be null
https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L83

ConfigResponse.Builder builder = ConfigResponse.builder();

if (json.hasNonNull(DEFAULTS)) {
builder.withDefaults(JsonUtil.getStringMapNullableValues(DEFAULTS, json));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this seems to specifically require a Map where the value can be null (see also #4184 (comment)) and there are also tests in TestConfigResponse that set values in a defaults/overrides map to null in order to be able to disable a particular configuration

property,
pNode);

Map<String, String> map = Maps.newHashMap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't use ImmutableMap here as it doesn't support null values

@nastra nastra requested a review from rdblue March 14, 2024 10:06
@nastra nastra requested a review from amogh-jahagirdar March 27, 2024 15:41

gen.writeStartObject();

JsonUtil.writeStringMap(DEFAULTS, response.defaults(), gen);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just change this to not send back the key in the response in the value is null (makes for a cleaner response? I don't really think that's a behavior change since in the end a client needs to check that the value is not null.


gen.writeStartObject();

JsonUtil.writeStringMap(DEFAULTS, response.defaults(), gen);
Copy link
Contributor

Choose a reason for hiding this comment

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

NVM these two fields are spec'd out so it seems like servers should always send it even though it may be null
https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L83

@nastra
Copy link
Contributor Author

nastra commented Apr 5, 2024

thanks for the review @amogh-jahagirdar

@nastra nastra merged commit 00f46ac into apache:main Apr 5, 2024
@nastra nastra deleted the config-response-parser branch April 5, 2024 16:14
sasankpagolu pushed a commit to sasankpagolu/iceberg that referenced this pull request Oct 27, 2024
zachdisc pushed a commit to zachdisc/iceberg that referenced this pull request Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants