You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/29 05:24:18 UTC

[GitHub] [pinot] saurabhd336 commented on a diff in pull request #8606: Add unrecognizedProperties to schema and tableConfigs APIs

saurabhd336 commented on code in PR #8606:
URL: https://github.com/apache/pinot/pull/8606#discussion_r861467331


##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java:
##########
@@ -243,13 +276,26 @@ public String validateSchema(FormDataMultiPart multiPart) {
   @ApiOperation(value = "Validate schema", notes = "This API returns the schema that matches the one you get "
       + "from 'GET /schema/{schemaName}'. This allows us to validate schema before apply.")
   @ApiResponses(value = {
-      @ApiResponse(code = 200, message = "Successfully validated schema"),
-      @ApiResponse(code = 400, message = "Missing or invalid request body"),
-      @ApiResponse(code = 500, message = "Internal error")
+      @ApiResponse(code = 200, message = "Successfully validated schema"), @ApiResponse(code = 400, message =
+      "Missing or invalid request body"), @ApiResponse(code = 500, message = "Internal error")
   })
-  public String validateSchema(Schema schema) {
+  public String validateSchema(String schemaJsonString) {
+    Pair<Schema, Map<String, Object>> schemaAndUnrecognizedProps = null;
+    try {
+      schemaAndUnrecognizedProps = JsonUtils.stringToObjectAndUnrecognizedProperties(schemaJsonString, Schema.class);
+    } catch (Exception e) {
+      String msg = String.format("Invalid schema config json string: %s", schemaJsonString);
+      throw new ControllerApplicationException(LOGGER, msg, Response.Status.BAD_REQUEST, e);
+    }
+    Schema schema = schemaAndUnrecognizedProps.getLeft();
     validateSchemaInternal(schema);
-    return schema.toPrettyJsonString();
+    ObjectNode response = schema.toJsonObject();
+    response.set("unrecognizedProperties", JsonUtils.objectToJsonNode(schemaAndUnrecognizedProps.getRight()));
+    try {
+      return JsonUtils.objectToPrettyString(response);

Review Comment:
   There's some formatting difference that way. This API used to return beautified json string. Keeping it same.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org