claudevdm commented on code in PR #40614:
URL: https://github.com/apache/beam/pull/40614#discussion_r4318377221
##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/ReadFooterSchema.java:
##########
@@ -161,29 +161,51 @@ private static void count(ReadResult result) {
private Callable<ReadResult> createReadTask(
String filePath, Instant timestamp, BoundedWindow window, PaneInfo
paneInfo) {
return () -> {
- FileFormat format;
- try {
- format = AddFiles.inferFormat(filePath);
- } catch (AddFiles.UnknownFormatException e) {
- return new ReadResult(dryRunMarker(UNREADABLE_KEY), false, timestamp,
window, paneInfo);
- }
- if (!format.equals(FileFormat.PARQUET)) {
- return new ReadResult(
- dryRunMarker(UNCHECKED_FORMAT_KEY), false, timestamp, window,
paneInfo);
+ ParquetMetadata footer;
+ if (AddFiles.hasNoExtension(filePath)) {
+ try {
+ footer = ParquetFooters.read(filePath);
+ } catch (Exception e) {
+ return unknownFormat(timestamp, window, paneInfo);
+ }
+ } else {
+ FileFormat format;
+ try {
+ format = AddFiles.inferFormat(filePath);
+ } catch (AddFiles.UnknownFormatException e) {
+ return unknownFormat(timestamp, window, paneInfo);
+ }
+ if (!format.equals(FileFormat.PARQUET)) {
+ return new ReadResult(
+ dryRunMarker(UNCHECKED_FORMAT_KEY), false, timestamp, window,
paneInfo);
+ }
+ try {
+ footer = ParquetFooters.read(filePath);
+ } catch (Exception e) {
+ return unreadableFooter(filePath, e, timestamp, window, paneInfo);
+ }
}
try {
- ParquetMetadata footer = ParquetFooters.read(filePath);
return new ReadResult(FileSchemas.schemaGroup(footer), false,
timestamp, window, paneInfo);
} catch (Exception e) {
- LOG.warn(
- "Could not read the footer of {}; the file will not contribute to
schema inference: {}",
- filePath,
- AddFiles.errorMessage(e));
- return new ReadResult(dryRunMarker(UNREADABLE_KEY), true, timestamp,
window, paneInfo);
Review Comment:
Converting the schema can still fail e.g. iceberg rejects unannotated
repeated field. I changed the messaging.
--
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]