amogh-jahagirdar commented on code in PR #16024:
URL: https://github.com/apache/iceberg/pull/16024#discussion_r3163773690


##########
core/src/main/java/org/apache/iceberg/rest/responses/ErrorResponseParser.java:
##########
@@ -46,9 +46,13 @@ public static String toJson(ErrorResponse errorResponse, 
boolean pretty) {
   public static void toJson(ErrorResponse errorResponse, JsonGenerator 
generator)
       throws IOException {
     generator.writeStartObject();
+    writeErrorField(errorResponse, generator);
+    generator.writeEndObject();
+  }
 
+  public static void writeErrorField(ErrorResponse errorResponse, 
JsonGenerator generator)

Review Comment:
   Does this need to be public? I feel like we should only expose 
fromJson/toJson from this parser implementation



##########
core/src/main/java/org/apache/iceberg/rest/responses/PlanTableScanResponseParser.java:
##########
@@ -98,6 +103,11 @@ public static PlanTableScanResponse fromJson(
         "Cannot parse planTableScan response from empty or null object");
 
     PlanStatus planStatus = PlanStatus.fromName(JsonUtil.getString(STATUS, 
json));
+    ErrorResponse errorResponse = null;
+    if (json.has(ERROR) && json.get(ERROR).isObject()) {

Review Comment:
   If it's not an object it violates the spec but I think the implementation 
being more robust like it is here makes a lot of sense, so +1 on how it's 
handled. It already failed so no need to blow up the parsing of the error; we 
may as well have the failure later on in the state tracking of the scan 
planning with a clearer error message. 



##########
core/src/main/java/org/apache/iceberg/rest/RESTTableScan.java:
##########
@@ -289,7 +291,8 @@ private CloseableIterable<FileScanTask> 
fetchPlanningResult() {
                 } else if (response.planStatus() != PlanStatus.COMPLETED) {
                   throw new IllegalStateException(
                       String.format(
-                          "Invalid planStatus: %s for planId: %s", 
response.planStatus(), id));
+                          "Invalid planStatus: %s for planId: %s. Server 
error: %s",
+                          response.planStatus(), id, response.errorMessage()));

Review Comment:
   I feel like we should only put "server error" in the message if it's 
non-null.



-- 
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]

Reply via email to