wombatu-kun opened a new pull request, #19251:
URL: https://github.com/apache/hudi/pull/19251
### Describe the issue this Pull Request addresses
Fixes #19250
`BasicStagedTable.newWriteBuilder` pattern-matches the `LogicalWriteInfo`
argument against `SupportsWrite` instead of matching the staged `Table`.
`SupportsWrite` is a `Table` mixin (`SupportsWrite extends Table`), and
`LogicalWriteInfo` is an unrelated interface, so the delegating branch can
never be taken: the method throws `HoodieException("Table `x` does not support
writes.")` for every input, including one whose underlying table is writable.
Present since #4611.
`BasicStagedTable` is what `HoodieCatalog` returns from `stageCreate`,
`stageReplace` and `stageCreateOrReplace` for non-Hudi tables, so an atomic
CTAS or RTAS against a writable V2 table goes through this method.
Scala compiles a match between two unrelated interfaces without a warning (a
class could in principle implement both), and no test ever exercised the class,
which is why this went unnoticed.
### Summary and Changelog
- Match on `table` rather than on `info` in
`BasicStagedTable.newWriteBuilder`, so a writable underlying table is delegated
to and only a genuinely non-writable one is rejected. This is what Spark's own
`BasicStagedTable` does via `table.asWritable`.
- Add `TestBasicStagedTable` covering both branches: delegation when the
underlying `Table` is `SupportsWrite`, and the `HoodieException` when it is
not. The first test fails on the current code with `Table `tbl` does not
support writes.` and passes after the fix.
### Impact
Writes staged through `HoodieCatalog` for a writable non-Hudi table now
reach the underlying table's `WriteBuilder` instead of being rejected. The
change can only turn an unconditional failure into a successful delegation; a
table that genuinely does not support writes is still rejected with the same
exception and message.
### Risk Level
low
### Documentation Update
none
### Contributor's checklist
- [x] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable
--
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]