You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Jonathan Weaver <my...@gmail.com> on 2022/09/15 22:42:45 UTC

SQL Engine Type inference when extending AsyncTableFunction class twice.

I am having an issue with the automatic type inference with SQL engine in
an AsyncTableFunction class.

I am extending AsyncTableFunction<RowData> in a BaseClass (common code).

Then extending again for some specific implementations.

FinalClass extends BaseClass

If I use BaseClass it correctly infers the output of the RowData from the
catalog.
If I use FinalClass it errors with

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.

So something with the typeInference is not looking at the right class in
the hierarchy.

I have tried overriding typeInformation at various points but it doesn't
seem to help.

Does anyone have an idea of how to have a common base class that gets
extended with correct automatic typeinference?

I can provide more details if needed.

Re: SQL Engine Type inference when extending AsyncTableFunction class twice.

Posted by Jonathan Weaver <my...@gmail.com>.
I think I've narrowed it down to this function in ExtractionUtils

    public static Optional<Class<?>> extractSimpleGeneric(
            Class<?> baseClass, Class<?> clazz, int pos) {
        try {
            if (clazz.getSuperclass() != baseClass) {
                return Optional.empty();
            }
            final Type t =
                    ((ParameterizedType) clazz.getGenericSuperclass())
                            .getActualTypeArguments()[pos];
            return Optional.ofNullable(toClass(t));
        } catch (Exception unused) {
            return Optional.empty();
        }
    }

clazz.superClasss() == "BaseClass" in my example and baseClass in the
function is expecting AsyncTableFunction<RowData> .. because that doesn't
compare it returns an empty result, even though it's correctly getting the
type inference elsewise.

Is there a way we could allow multiple extends in the future, instead of
just allowing a direct single subclass?



On Thu, Sep 15, 2022 at 4:42 PM Jonathan Weaver <my...@gmail.com>
wrote:

> I am having an issue with the automatic type inference with SQL engine in
> an AsyncTableFunction class.
>
> I am extending AsyncTableFunction<RowData> in a BaseClass (common code).
>
> Then extending again for some specific implementations.
>
> FinalClass extends BaseClass
>
> If I use BaseClass it correctly infers the output of the RowData from the
> catalog.
> If I use FinalClass it errors with
>
> 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.
>
> So something with the typeInference is not looking at the right class in
> the hierarchy.
>
> I have tried overriding typeInformation at various points but it doesn't
> seem to help.
>
> Does anyone have an idea of how to have a common base class that gets
> extended with correct automatic typeinference?
>
> I can provide more details if needed.
>