-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Indicate what fields are getting ignored when adding configs #8514
Conversation
GH Issue: #8318 |
Codecov Report
@@ Coverage Diff @@
## master #8514 +/- ##
============================================
- Coverage 70.65% 69.61% -1.05%
+ Complexity 4314 4313 -1
============================================
Files 1692 1693 +1
Lines 88751 88786 +35
Branches 13468 13470 +2
============================================
- Hits 62708 61806 -902
- Misses 21657 22611 +954
+ Partials 4386 4369 -17
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
8980030
to
55f7d2b
Compare
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 awesome! I can see it improve user experience drastically!
import java.util.Map; | ||
|
||
public final class ConfigSuccessResponse extends SuccessResponse { | ||
private final Map<String, Object> _unparseableProps; |
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.
Suggest renaming the field, same for other places
private final Map<String, Object> _unparseableProps; | |
private final Map<String, Object> _ unrecognizedProperties; |
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.
Ack
|
||
public static <T> T stringToObject(String jsonString, Class<T> valueType) | ||
throws IOException { | ||
return DEFAULT_READER.forType(valueType).readValue(jsonString); | ||
} | ||
|
||
public static <T> JsonPojoWithUnparsableProps<T> stringToObjectAndUnparseableProps(String jsonString, Class<T> klass) |
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.
Name the second parameter valueType
for consistency
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.
(optional) I feel returning a Pair<T, Map<String, Object>>
should be enough
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.
Ack on https://github.com/apache/pinot/pull/8514/files#r855450400
#2 The Pair class defined within the project expects 'T' to be extending Serializable, which would mean changing the base response classes. Other Pair implementations would need dependencies. Leaving it as it is for now.. Will revisit.
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.
Can we use org.apache.commons.lang3.tuple.Pair
? I think we should already have the dependency
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.
Ack
int _primitiveIntegerField; | ||
String _stringField; | ||
Long _longField; | ||
Klass _classField; |
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.
(minor) I think we use Clazz
in most of the places
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.
Ack
} | ||
|
||
private static Stream<Map.Entry<String, Object>> flatten(Map.Entry<String, Object> entry) { | ||
|
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.
(nit) remove empty line
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.
Ack
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.
looking good so far! minior comments
@@ -492,18 +498,22 @@ public SuccessResponse updateTableConfig( | |||
@ApiOperation(value = "Validate table config for a table", | |||
notes = "This API returns the table config that matches the one you get from 'GET /tables/{tableName}'." | |||
+ " This allows us to validate table config before apply.") | |||
public String checkTableConfig( | |||
public ObjectNode checkTableConfig( |
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 take this opportunity to also wrap this into a ConfigValidationResponse object?
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.
I checked this. But it's getting a little tricky to do it in a backward compatible way. Since ConfigSuccessResponse extends SuccesResponse while this function returns a custom object..
|
||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class TestClass { |
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 this just be inside JsonUtilsTest? It's very non-generic to be by itself
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.
Jackson is not able to work with inner classes. Hence had added it here.
Renamed to something more relevant
ControllerTestUtils | ||
.sendPostRequest(StringUtil.join("/", ControllerTestUtils.getControllerBaseApiUrl(), "tables", "validate"), | ||
offlineTableConfig.toJsonString()); | ||
ControllerTestUtils.sendPostRequest( |
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.
would be nice to have couple of tests in validate.
- validation success, but unparseable props
- validation failed
to make sure both these experiences are unaffected by this change
(optional) test case in add and update too
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.
Added unrecognizedProperties tests for add, update and validate table APIs.
Validation failed tests already exist for all APIs.
fd9519d
to
0f9cea5
Compare
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.
lgtm
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.
LGTM. Only minor comments
|
||
public static <T> T stringToObject(String jsonString, Class<T> valueType) | ||
throws IOException { | ||
return DEFAULT_READER.forType(valueType).readValue(jsonString); | ||
} | ||
|
||
public static <T> Pair<T, Map<String, Object>> stringToObjectAndUnparseableProps(String jsonString, |
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.
Suggest renaming
public static <T> Pair<T, Map<String, Object>> stringToObjectAndUnparseableProps(String jsonString, | |
public static <T> Pair<T, Map<String, Object>> stringToObjectAndUnrecognizedProperties(String jsonString, |
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.
Ack
@@ -273,6 +274,20 @@ public void testFlatten() | |||
} | |||
} | |||
|
|||
@Test | |||
public void testUnparseableJson() throws Exception { |
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.
Suggest renaming
public void testUnparseableJson() throws Exception { | |
public void testUnrecognizedProperties() throws Exception { |
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.
Ack
String tableConfigStr, | ||
@ApiParam(value = "comma separated list of validation type(s) to skip. supported types: (ALL|TASK|UPSERT)") | ||
@QueryParam("validationTypesToSkip") @Nullable String typesToSkip, @Context HttpHeaders httpHeaders, | ||
@Context Request request) { | ||
// TODO introduce a table config ctor with json string. | ||
Pair<TableConfig, Map<String, Object>> tableConfigAndUnparsedProps; |
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.
Suggest renaming
Pair<TableConfig, Map<String, Object>> tableConfigAndUnparsedProps; | |
Pair<TableConfig, Map<String, Object>> tableConfigAndUnrecognizedProperties; |
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.
Ack
0f9cea5
to
00d6277
Compare
00d6277
to
2759e75
Compare
2759e75
to
d634396
Compare
This PR is a follow up of #8514. It adds the "unrecognizedProperties" fields to /schemas and /tableConfigs APIs
This PR adds "unrecognizedProperties" to POST /tables/, PUT /tables/{tableName} and POST /tables/validate. This field will be a flattened map of json keys to values that will let the API users know when certain field(s) in the input config json are being ignored.