nastra commented on code in PR #5407: URL: https://github.com/apache/iceberg/pull/5407#discussion_r978510452
########## core/src/main/java/org/apache/iceberg/rest/requests/ScanReportRequest.java: ########## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.rest.requests; + +import org.apache.iceberg.metrics.ScanReport; +import org.apache.iceberg.relocated.com.google.common.base.MoreObjects; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.rest.RESTRequest; + +public class ScanReportRequest implements RESTRequest { Review Comment: I have been going over the approach you suggested a few times over a few different days, but every time I'm arriving at the same conclusion where I have the feeling that we're pushing too much stuff into `ScanReportParser`. I understand that there is a precedent for embedding the type field in the JSON object but I does not feel right to me to apply this here. I believe the `ScanReportParser` should not care about other metric types and its only responsibility should be to define how to ser/de a `ScanReport`. It should also not care or know that there might be a `CommitReport` in the future or any other report type. That way the responsibility of the `ScanReportParser` is well defined and can be tested without any other **dependencies**. Once we have a `CommitReport`, there should be a `CommitReportParser`, which is only responsible for `CommitReport` things. The fact that we're using a generic endpoint to send reports/metrics to should not affect any of those existing `ScanReportParser`/`CommitReportParser`/`XParser` parsers in any way. We should have a separate parser (`SendMetricsRequestParser` in the PR) that properly handles how reports/metrics should be sent to this generic endpoint. And this parser should be re-using `ScanReportParser`/`CommitReportParser`/`XParser` or any other parsers to properly ser/de the different types it is supporting. After all, what if we decide in the future to use report-specific endpoints? We'd have to rewrite a bunch of things, because parsers contained more code than just what's exactly relevant to ser/de a particular instance of a class. That being said, the cost of introducing a `SendMetricsRequest`/`SendMetricsRequestParser` to deal with the fact that we're using a generic endpoint for different report types gives me a strong feeling that it's the correct/right approach here, because we're not leaking responsibility into other parsers. Additionally, the code in both of those classes is fairly short and easy to grasp, so that it's immediately obvious that the purpose of those two classes is to deal with different report types. -- 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]
