[FLINK-36152] Fix incorrect type extraction in case of cascaded inheritance when DataTypeHint is not configured
What is the purpose of the change
Fix incorrect type extraction in case of cascaded inheritance when DataTypeHint is not configured.
In our case, there's a ConcreteLookupFunction extends AbstractLookupFunction, and AbstractLookupFunction extends TableFunction<RowData>.
However Class#getGenericSuperclass only return the direct superclass, so it cannot extract the correct generic type RowData.
I can reproduce the exception below:
// flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/FunctionITCase.java
@Test
void testLookupTableFunctionWithoutHintLevel2()
throws ExecutionException, InterruptedException {
testLookupTableFunctionBase(LookupTableWithoutHintLevel2Function.class.getName());
}
// ... ...
public static class LookupTableWithoutHintLevel2Function
extends LookupTableWithoutHintLevel1Function {}
org.apache.flink.table.api.ValidationException: Cannot extract a data type from an internal 'org.apache.flink.table.data.RowData' class without further information. Please use annotations to define the full logical type.
at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:424)
at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:419)
at org.apache.flink.table.types.extraction.DataTypeExtractor.checkForCommonErrors(DataTypeExtractor.java:425)
at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrError(DataTypeExtractor.java:330)
at org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRawWithTemplate(DataTypeExtractor.java:290)
... 53 more
Brief change log
- Iterate through the superclass hierarchy of a given class to extract generic type.
Verifying this change
This change added tests and can be verified as follows:
- Added test that validates that multi-levels inheritance in FunctionITCase.
Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with
@Public(Evolving): (no) - The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
Documentation
- Does this pull request introduce a new feature? (no)
CI report:
- 3f1b92e8d262a3a601624ade2b17bf126f553117 Azure: SUCCESS
Bot commands
The @flinkbot bot supports the following commands:@flinkbot run azurere-run the last Azure build
@flinkbot run azure
This PR is being marked as stale since it has not had any activity in the last 90 days. If you would like to keep this PR alive, please leave a comment asking for a review. If the PR has merge conflicts, update it with the latest from the base branch.
If you are having difficulty finding a reviewer, please reach out to the community, contact details can be found here: https://flink.apache.org/what-is-flink/community/
If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.
This PR has been closed since it has not had any activity in 120 days. If you feel like this was a mistake, or you would like to continue working on it, please feel free to re-open the PR and ask for a review.