Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-20725

TableFunction#getTypeInference is not work well for JdbcRowDataLookupFunction, it's always throws Exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.13.0
    • Fix Version/s: None
    • Component/s: Table SQL / API
    • Labels:
      None

      Description

      I found that TableFunction#getTypeInference  is not work well for JdbcRowDataLookupFunction , it's always throws Exception.

       

      When I add following test in JdbcRowDataLookupFunctionTest and run it:

      @Test
      public void testTypeInference() {
         final TableEnvironment env = TableEnvironment.create(EnvironmentSettings
            .newInstance().build());
      
         final DataTypeFactory dataTypeFactory = ((TableEnvironmentInternal) env)
            .getCatalogManager()
            .getDataTypeFactory();
      
         JdbcRowDataLookupFunction lookupFunction = buildRowDataLookupFunction();
      
         lookupFunction.getTypeInference(dataTypeFactory);
      }
      

       

      it always throws following exception:

       

      Test testTypeInference(org.apache.flink.connector.jdbc.table.JdbcRowDataLookupFunctionTest) failed with:
      org.apache.flink.table.api.ValidationException: Could not extract a valid type inference for function class 'org.apache.flink.connector.jdbc.table.JdbcRowDataLookupFunction'. 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.table.JdbcRowDataLookupFunctionTest.testTypeInference(JdbcRowDataLookupFunctionTest.java:103)
      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 more
      Caused by: org.apache.flink.table.api.ValidationException: Unable to extract a type inference from method:
      public void org.apache.flink.connector.jdbc.table.JdbcRowDataLookupFunction.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 more
      Caused by: org.apache.flink.table.api.ValidationException: Could not extract a data type from 'interface org.apache.flink.table.data.RowData' in generic class 'org.apache.flink.table.functions.TableFunction' in class org.apache.flink.connector.jdbc.table.JdbcRowDataLookupFunction. 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 more
      Caused by: 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:359) 
          at org.apache.flink.table.types.extraction.ExtractionUtils.extractionError(ExtractionUtils.java:351) 
          at org.apache.flink.table.types.extraction.DataTypeExtractor.checkForCommonErrors(DataTypeExtractor.java:401) 
          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
      

       

      I guess this problem also exists in other LookupFunction implementations. And the reason why there was no problem when running itcase(JdbcLookupTableITCase) is that the exception was caught and handled in LookupJoinCodeGenerator#createLookupTypeInference.

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                wanglijie95 Lijie Wang
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: