[ENG-41614] Introduce TableFormatDetector SPI (Hudi-only) - #190
Merged
Conversation
Extracts the hardcoded `.hoodie/` check in `TableDiscoveryService` into a `TableFormatDetector` interface with one implementation per format. Only `HudiTableFormatDetector` is registered today, so behavior is unchanged: every `Database` (including those with no `tableFormat` set in YAML) is treated as Hudi. The new `TableFormat` enum carries `HUDI` and `ICEBERG` values with `@JsonProperty` aliases for the proto enum names — the latter is unused in this PR but lets the wire shape settle before the Iceberg detector and uploader land in the follow-up. Refactor only. The Iceberg detector + uploader, `Database.tableHints`, `Table.tableFormat`, `s3a://` URI scheme, and the dispatch-by-format routing in `TableDiscoveryAndUploadJob` ship in the follow-up PR.
added 3 commits
May 22, 2026 11:53
`TableDiscoveryService` gained a `HudiTableFormatDetector` constructor argument; `LakeviewSyncTool` constructs it directly (no Guice) and was left out of the previous commit. Pass `new HudiTableFormatDetector()` to match.
The intermediate `directories` list is only iterated, never modified. Switching to an unmodifiable collector addresses the SonarQube hint without depending on `Stream.toList()` (Java 16+) — project still targets a lower bytecode level.
CI runs on Java 8 where neither `Stream.toList()` (16+) nor `Collectors.toUnmodifiableList()` (10+) is available. The SonarQube hint is a non-blocking suggestion; matching the rest of the codebase takes priority.
|
vishalk9
approved these changes
May 22, 2026
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Sub-PR 1 of 2 splitting #189. Pure refactor — extracts the hardcoded
.hoodie/check inTableDiscoveryServiceinto aTableFormatDetectorSPI with one implementation per format. OnlyHudiTableFormatDetectoris registered today, so behavior is unchanged: everyDatabase(including those with notableFormatin YAML) routes through the Hudi detector.What changed
New
TableFormatenum (HUDI,ICEBERG) with@JsonPropertyaliases matching the protobuf enum names (TABLE_FORMAT_HUDI,TABLE_FORMAT_ICEBERG).ICEBERGis unused in this PR but lets the wire shape settle before the iceberg detector + uploader land.TableFormatDetectorSPI interface — asyncmatches(path, listedFiles)so future detectors can do follow-up listings without a refactor.HudiTableFormatDetector— same logic as the oldisHudiTableFolder(anyMatch(filename startsWith .hoodie)), moved behind the SPI.TestHudiTableFormatDetector— unit coverage.Modified
Database— adds nullabletableFormatfield. Null is interpreted asHUDIfor backward compatibility with existing YAMLs.TableDiscoveryService— usesMap<TableFormat, TableFormatDetector>and picks the detector bydatabase.getTableFormat()(null → HUDI). The detector map currently has only the HUDI entry.TableDiscoveryServiceTest— constructor signature update.Hudi safety
tableFormat) still discover Hudi tablesdetectorForHudiTableFormatDetector.matchesis byte-for-byte the oldisHudiTableFolderTableMetadataUploaderService(Hudi upload path) untouched:lakeview:testsuite passes locallyOut of scope (follow-up PR)
The iceberg-specific pieces from #189 are deferred:
IcebergTableFormatDetector+IcebergMetadataUploaderServiceDatabase.tableHints+TableHintTable.tableFormat,Table.metadataLocationHintTableDiscoveryAndUploadJob.dispatchUploadroutingInitializeTableMetricsCheckpointRequest.tableFormats3a://inOBJECT_STORAGE_URI_PATTERNdocs/iceberg-support.mdTest plan
./gradlew :lakeview:testgreen locally (full suite)TableDiscoveryServiceTest(existing) passes unchanged behaviorTestHudiTableFormatDetectorcovers detector contract + iceberg-shape negative case