Lijie Wang created FLINK-20725:
----------------------------------
Summary: TableFunction#getTypeInference is not work well for
JdbcRowDataLookupFunction, it's always throws Exception
Key: FLINK-20725
URL: https://issues.apache.org/jira/browse/FLINK-20725
Project: Flink
Issue Type: Bug
Components: Table SQL / API
Affects Versions: 1.13.0
Reporter: Lijie Wang
I find that TableFunction#getTypeInference is not work well for
JdbcRowDataLookupFunction , it's always throws Exception.
When I add following test in JdbcLookupFunctionTest and run it:
{code:java}
@Test
public void testTypeInference() {
final TableEnvironment env = TableEnvironment.create(EnvironmentSettings
.newInstance().build());
final DataTypeFactory dataTypeFactory = ((TableEnvironmentInternal) env)
.getCatalogManager()
.getDataTypeFactory();
JdbcLookupFunction lookupFunction = buildLookupFunction();
lookupFunction.getTypeInference(dataTypeFactory);
}
{code}
it always throws following exception:
{code:java}
Test testTypeInference(org.apache.flink.connector.jdbc.JdbcLookupFunctionTest)
failed with:Test
testTypeInference(org.apache.flink.connector.jdbc.JdbcLookupFunctionTest)
failed with:org.apache.flink.table.api.ValidationException: Could not extract a
valid type inference for function class
'org.apache.flink.connector.jdbc.table.JdbcLookupFunction'. Please check for
implementation mistakes and/or provide a corresponding hint. at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:359)
at
org.apache.flink.table.types.extraction.TypeInferenceExtractor.extractTypeInference(TypeInferenceExtractor.java:160)
at
org.apache.flink.table.types.extraction.TypeInferenceExtractor.forTableFunction(TypeInferenceExtractor.java:119)
at
org.apache.flink.table.functions.TableFunction.getTypeInference(TableFunction.java:212)
at
org.apache.flink.connector.jdbc.JdbcLookupFunctionTest.testTypeInference(JdbcLookupFunctionTest.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at
org.junit.rules.RunRules.evaluate(RunRules.java:20) at
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at
org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) at
org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) at
org.junit.rules.RunRules.evaluate(RunRules.java:20) at
org.junit.runners.ParentRunner.run(ParentRunner.java:363) at
org.junit.runner.JUnitCore.run(JUnitCore.java:137) at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)Caused by:
org.apache.flink.table.api.ValidationException: Error in extracting a signature
to output mapping. at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:359)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractOutputMapping(FunctionMappingExtractor.java:118)
at
org.apache.flink.table.types.extraction.TypeInferenceExtractor.extractTypeInferenceOrError(TypeInferenceExtractor.java:170)
at
org.apache.flink.table.types.extraction.TypeInferenceExtractor.extractTypeInference(TypeInferenceExtractor.java:158)
... 32 moreCaused by: org.apache.flink.table.api.ValidationException: Unable
to extract a type inference from method:public void
org.apache.flink.connector.jdbc.table.JdbcLookupFunction.eval(java.lang.Object[])
at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:359)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractResultMappings(FunctionMappingExtractor.java:175)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractOutputMapping(FunctionMappingExtractor.java:113)
... 34 moreCaused by: org.apache.flink.table.api.ValidationException: Could
not extract a data type from 'class org.apache.flink.types.Row' in generic
class 'org.apache.flink.table.functions.TableFunction' in class
org.apache.flink.connector.jdbc.table.JdbcLookupFunction. Please pass the
required data type manually or allow RAW types. at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:359)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRawWithTemplate(DataTypeExtractor.java:273)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRaw(DataTypeExtractor.java:249)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeWithClassContext(DataTypeExtractor.java:223)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractFromGeneric(DataTypeExtractor.java:144)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.lambda$createGenericResultExtraction$13(FunctionMappingExtractor.java:467)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.putExtractedResultMappings(FunctionMappingExtractor.java:312)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.collectMethodMappings(FunctionMappingExtractor.java:255)
at
org.apache.flink.table.types.extraction.FunctionMappingExtractor.extractResultMappings(FunctionMappingExtractor.java:167)
... 35 moreCaused by: org.apache.flink.table.api.ValidationException: Cannot
extract a data type from a pure 'org.apache.flink.types.Row' class. Please use
annotations to define field names and field types. at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:359)
at
org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:351)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.checkForCommonErrors(DataTypeExtractor.java:390)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrError(DataTypeExtractor.java:304)
at
org.apache.flink.table.types.extraction.DataTypeExtractor.extractDataTypeOrRawWithTemplate(DataTypeExtractor.java:265)
... 42 more
{code}
I guess this problem also exists in other LookupFunction implementations. And
the reason why there is no problem when running itcase(JdbcLookupTableITCase)
is that the exception is catched and handled in
LookupJoinCodeGenerator#createLookupTypeInference.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)