voonhous commented on code in PR #19253:
URL: https://github.com/apache/hudi/pull/19253#discussion_r3881747865
##########
hudi-hadoop-common/src/test/java/org/apache/hudi/io/hadoop/TestHoodieHadoopIOFactory.java:
##########
@@ -61,9 +68,50 @@ public void testGetFileFormatUtils() throws IOException {
assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.ORC) instanceof
OrcUtils);
assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.HFILE)
instanceof HFileUtils);
assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.LANCE)
instanceof LanceUtils);
+ assertTrue(ioFactory.getFileFormatUtils(HoodieFileFormat.VORTEX)
instanceof VortexUtils);
assertThrows(
UnsupportedOperationException.class,
() -> ioFactory.getFileFormatUtils(HoodieFileFormat.HOODIE_LOG));
}
}
+
+ /**
+ * {@link HoodieIOFactory#getFileFormatUtils(StoragePath)} maps the file
extension to a format
+ * through its own if-chain before delegating to the {@link
HoodieFileFormat} switch in
+ * {@link HoodieHadoopIOFactory#getFileFormatUtils(HoodieFileFormat)}. A
format added to one
+ * dispatch point but missed in the other only fails at runtime, so this
sweeps every enum value
+ * (never a hardcoded list) and requires both entry points to agree: the
same utils class, or
+ * {@link UnsupportedOperationException} from both. Any other exception type
propagates.
+ */
+ @ParameterizedTest
+ @EnumSource(HoodieFileFormat.class)
+ void testGetFileFormatUtilsEntryPointsAgreeForEveryFormat(HoodieFileFormat
format) throws IOException {
+ try (HoodieStorage storage = newStorage()) {
+ HoodieIOFactory ioFactory = new HoodieHadoopIOFactory(storage);
+ StoragePath path = new StoragePath("file:///a/b" +
format.getFileExtension());
+ Option<Class<?>> byFormat = fileFormatUtilsClass(() ->
ioFactory.getFileFormatUtils(format));
+ Option<Class<?>> byPath = fileFormatUtilsClass(() ->
ioFactory.getFileFormatUtils(path));
+ assertEquals(byFormat, byPath, () -> String.format(
Review Comment:
Done in 37c870633a17: the sweep now excludes `HOODIE_LOG` and calls both
entry points directly, so a case missing from the switch or from the if-chain
surfaces as the production `UnsupportedOperationException`; the `Option` helper
is gone.
--
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]