Jackie-Jiang commented on a change in pull request #8357:
URL: https://github.com/apache/pinot/pull/8357#discussion_r827476107
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
##########
@@ -251,14 +249,27 @@ public String validateSchema(FormDataMultiPart multiPart)
{
@ApiResponse(code = 500, message = "Internal error")
})
public String validateSchema(Schema schema) {
+ validateSchemaInternal(schema);
+ return schema.toPrettyJsonString();
+ }
+
+ private void validateSchemaName(Schema schema) {
+ if (StringUtils.isBlank(schema.getSchemaName())) {
+ throw new ControllerApplicationException(LOGGER,
+ "Invalid schema: " + schema.getSchemaName() + ". Reason:
'schemaName' should not be null",
+ Response.Status.BAD_REQUEST);
+ }
+ }
+
+ private void validateSchemaInternal(Schema schema) {
try {
+ Preconditions.checkNotNull(schema.getSchemaName(), "'schemaName' should
not be null");
Review comment:
```suggestion
private void validateSchemaInternal(Schema schema) {
validateSchemaName(Schema schema);
try {
```
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
##########
@@ -251,14 +249,27 @@ public String validateSchema(FormDataMultiPart multiPart)
{
@ApiResponse(code = 500, message = "Internal error")
})
public String validateSchema(Schema schema) {
+ validateSchemaInternal(schema);
+ return schema.toPrettyJsonString();
+ }
+
+ private void validateSchemaName(Schema schema) {
Review comment:
(minor) Consider directly put `String schemaName` as parameter
##########
File path:
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotSchemaRestletResource.java
##########
@@ -251,14 +249,27 @@ public String validateSchema(FormDataMultiPart multiPart)
{
@ApiResponse(code = 500, message = "Internal error")
})
public String validateSchema(Schema schema) {
+ validateSchemaInternal(schema);
+ return schema.toPrettyJsonString();
+ }
+
+ private void validateSchemaName(Schema schema) {
+ if (StringUtils.isBlank(schema.getSchemaName())) {
+ throw new ControllerApplicationException(LOGGER,
+ "Invalid schema: " + schema.getSchemaName() + ". Reason:
'schemaName' should not be null",
Review comment:
This exception message is not very readable as schema name is always
blank. Consider changing it to `'schemaName' must be provided`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]