ocb3916 opened a new pull request, #4441:
URL: https://github.com/apache/streampark/pull/4441

   ## What is the purpose of the change
   
   Implements Phase 0.2 of the Scala removal plan (#4408).
   
   Defines `FlinkTableJob` and `FlinkStreamTableJob` as the Java abstract base 
classes that will
   eventually replace the Scala `FlinkTableTrait` and `FlinkStreamTableTrait` 
traits — for Table API
   (batch) jobs and jobs that mix the DataStream API with the Table API, 
respectively. Both classes
   live in the existing `streampark-flink-shims-base` module and follow the same
   `ready → handle → destroy` lifecycle established by `FlinkStreamingJob` in 
sub-issue 0.1, so all
   three "Job" base classes share a consistent shape.
   
   ## Brief change log
   
   - Add `FlinkTableJob` abstract class with lifecycle: `ready → handle → 
destroy`, exposing the
     underlying `TableEnvironment` via `getTableEnv()` (composition) instead of 
extending / mimicking
     the interface like the legacy trait did
   - Add `FlinkStreamTableJob` abstract class with the same lifecycle, exposing 
both
     `StreamExecutionEnvironment` (`getEnv()`) and `StreamTableEnvironment` 
(`getTableEnv()`) via
     composition
   - Add `sql(String)` / `sql(String, Consumer<String>)` on both classes, 
bridging to the existing
     Scala `FlinkSqlExecutor.executeSql` so the public API surface stays 
Scala-free
   - Add `markConvertedToDataStream()` on `FlinkStreamTableJob`, replacing the 
legacy trait's
     automatic `Table → DataStream` conversion detection (no longer possible 
under composition) with
     an explicit call
   - Place both classes under `org.apache.streampark.flink.core.javaapi` rather 
than the
     issue-specified `org.apache.streampark.flink.core.java` — see note below
   - Add JUnit 5 tests for both classes verifying lifecycle order, 
`getTableEnv()`/`getEnv()`
     composition, SQL execution, and the `markConvertedToDataStream()` flag
   
   ## A note on the package name
   
   The issue body specifies `org.apache.streampark.flink.core.java`. That name 
breaks Scala
   compilation of every sibling file in `streampark-flink-shims-base` that 
references
   `java.util`/`java.io`/`java.lang` — a nested package literally named `java` 
shadows the real
   `java.*` standard library for any Scala file sharing the enclosing package. 
Reproduced both ways
   in a clean build:
   
   - `org.apache.streampark.flink.core.java` → `BUILD FAILURE`, 33 errors, all 
`java.util`/`java.io`/
     `java.lang` unresolved in unrelated sibling `.scala` files
   - `org.apache.streampark.flink.core.javaapi` → `BUILD SUCCESS`, no other 
files affected
   
   Went with `javaapi` for this PR. Open to other naming suggestions if 
`javaapi` isn't preferred.
   
   ## Design note: composition instead of full delegation
   
   The legacy traits extend/mimic Flink's `TableEnvironment` / 
`StreamTableEnvironment` directly,
   re-implementing ~40-50 delegate methods each (`FlinkStreamTableTrait` 
additionally needed a
   `$`-prefix naming hack to avoid clashes between the two APIs). The new 
classes hold the
   environment(s) as fields instead, exposed via `getTableEnv()` / `getEnv()`. 
This removes the
   delegate boilerplate and the naming hack, and means the classes won't go 
stale as the Flink Table
   API changes — but it **is a breaking change** for code that currently calls 
Table API methods
   directly on a trait instance (e.g. `job.sqlQuery(...)` → 
`job.getTableEnv().sqlQuery(...)`).
   Flagging for discussion since the Phase 11 migration guide will need to 
cover it.
   
   ## Verifying this change
   
   ```bash
   mvn test -pl 
streampark-flink/streampark-flink-shims/streampark-flink-shims-base
   ```
   
   Tests run: 9, Failures: 0, Errors: 0
   
   ## Does this pull request potentially affect one of the following parts?
   
   - [x] The public API
   - [ ] The web application
   - [ ] The build system
   
   ## Documentation
   
   - Relates to issue #4408
   - Part of umbrella issue #4408, sub-issue 0.2


-- 
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]

Reply via email to