public static boolean isClassNameSerializable(UserDefinedFunction function) {
        final Class<?> functionClass = function.getClass();
        if (!InstantiationUtil.hasPublicNullaryConstructor(functionClass)) {
            // function must be parameterized
            return false;
        }
        Class<?> currentClass = functionClass;
        while (!currentClass.equals(UserDefinedFunction.class)) {
            for (Field field : currentClass.getDeclaredFields()) {
                if (!Modifier.isTransient(field.getModifiers())
                        && !Modifier.isStatic(field.getModifiers())) {
                    // function seems to be stateful
                    return false;
                }
            }
            currentClass = currentClass.getSuperclass();
        }
        return true;
    }
@Test
    void testSerialization() {
        assertThat(isClassNameSerializable(new ValidTableFunction())).isTrue();

        assertThat(isClassNameSerializable(new ValidScalarFunction())).isTrue();

        assertThat(isClassNameSerializable(new ParameterizedTableFunction(12))).isFalse();

        assertThat(isClassNameSerializable(new StatefulScalarFunction())).isFalse();
    }