class TableFunctionFactory {

    public static TableFunctionImplementation<?> from(FunctionImplementation functionImplementation) {<FILL_FUNCTION_BODY>}

    /**
     * Evaluates the {@link Scalar} function and emits scalar result as a 1x1 table
     */
    private static class ScalarTableFunctionImplementation<T> extends TableFunctionImplementation<T> {

        private final Scalar<?, T> functionImplementation;
        private final RowType returnType;

        private ScalarTableFunctionImplementation(Scalar<?, T> functionImplementation) {
            super(
                Signature.table(
                    functionImplementation.signature().getName(),
                    Lists.concat(
                        functionImplementation.signature().getArgumentTypes(),
                        functionImplementation.signature().getReturnType()
                    ).toArray(new TypeSignature[0])
                ),
                new BoundSignature(
                    functionImplementation.boundSignature().argTypes(),
                    functionImplementation.boundSignature().returnType()
                )
            );
            this.functionImplementation = functionImplementation;
            var boundReturnType = functionImplementation.boundSignature().returnType();
            returnType = new RowType(
                List.of(boundReturnType),
                List.of(functionImplementation.signature().getName().name())
            );
        }

        @Override
        public Iterable<Row> evaluate(TransactionContext txnCtx, NodeContext nodeCtx, Input<T>[] args) {
            return List.of(new Row1(functionImplementation.evaluate(txnCtx, nodeCtx, args)));
        }

        @Override
        public RowType returnType() {
            return returnType;
        }

        @Override
        public boolean hasLazyResultSet() {
            return true;
        }
    }
}

        TableFunctionImplementation<?> tableFunction;
        switch (functionImplementation.signature().getKind()) {
            case TABLE:
                tableFunction = (TableFunctionImplementation<?>) functionImplementation;
                break;
            case SCALAR:
                tableFunction = new ScalarTableFunctionImplementation<>((Scalar<?, ?>) functionImplementation);
                break;
            case WINDOW:
            case AGGREGATE:
                throw new UnsupportedOperationException(
                    String.format(
                        Locale.ENGLISH,
                        "Window or Aggregate function: '%s' is not allowed in function in FROM clause",
                        functionImplementation.signature().getName().displayName()));
            default:
                throw new UnsupportedOperationException(
                    String.format(
                        Locale.ENGLISH,
                        "Unknown type function: '%s' is not allowed in function in FROM clause",
                        functionImplementation.signature().getName().displayName()));
        }
        return tableFunction;
    
<no_super_class>