pvary commented on code in PR #18541:
URL: https://github.com/apache/iceberg/pull/18541#discussion_r4296264509
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/TableMetadataCache.java:
##########
@@ -197,6 +197,17 @@ private ResolvedSchemaInfo schema(
}
Review Comment:
Maybe put this to a new method, like:
```suggestion
} else {
cacheResult(cached, input, compatible)
}
```
Or maybe put the `for` loop into its own method like:
```
private ResolvedSchemaInfo compareWithTableSchemas(CacheItem cached,
Schema input) {
Schema compatible = null;
for (Schema tableSchema : cached.tableSchemas.values()) {
CompareSchemasVisitor.Result result =
CompareSchemasVisitor.visit(input, tableSchema, caseSensitive,
dropUnusedColumns);
if (result == CompareSchemasVisitor.Result.SAME) {
return new ResolvedSchemaInfo(tableSchema, result,
DataConverter.identity());
} else if (compatible == null
&& result == CompareSchemasVisitor.Result.DATA_CONVERSION_NEEDED) {
compatible = tableSchema;
}
}
if (compatible == null) {
return NOT_FOUND;
}
return new ResolvedSchemaInfo(
compatible,
CompareSchemasVisitor.Result.DATA_CONVERSION_NEEDED,
DataConverter.get(
FlinkSchemaUtil.convert(input),
FlinkSchemaUtil.convert(compatible), caseSensitive));
}
```
The original `cachedSchema` method is a minimal change, but only fixes the
warning, not the real complexity issue.
--
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]