[
https://issues.apache.org/jira/browse/FLINK-31368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698281#comment-17698281
]
Timo Walther commented on FLINK-31368:
--------------------------------------
Big +1 on this. We cleaned TableEnvironment during the Blink merge but with
every release it grew in size again.
Whenever there is a long list of {{else if (x instanceof ClassX)}} patterns,
the implementation should be improved. Ideally there should be just a class
like:
{code}
OperationExecutor<O extends Operation> {
Class<O> supportedOperation();
Tuple2<Header, List<Row>> apply(O);
}
ShowTablesExecutor<ShowTablesOperation> extends AbstractOperationExecutor {
ShowTablesExecutor() {
super(ShowTablesOperation.class);
}
}
{code}
And a map that lists all executors:
{code}
Map<Class, OperationExecutor<?>> executors = new HashMap<>;
static {
add(ShowTablesExecutor.class);
}
add(Class c) {
var i = c.newInstance()
executors.put(i.supportedOperation(), i);
}
{code}
> Move operation execution logic out from TableEnvironmentImpl
> ------------------------------------------------------------
>
> Key: FLINK-31368
> URL: https://issues.apache.org/jira/browse/FLINK-31368
> Project: Flink
> Issue Type: Technical Debt
> Components: Table SQL / Planner
> Reporter: Jark Wu
> Priority: Major
>
> Currently, {{TableEnvironmentImpl}} is a bit bloated. The implementation of
> {{TableEnvironmentImpl}} is filled with lots of operation execution logic
> which makes the class hard to read and maintain. Once you want to add/update
> an operation, you have to touch the {{TableEnvironmentImpl}}, which is
> unnecessary and not clean.
> An improvement idea is to extract the operation execution logic (mainly the
> command operation, which doesn't trigger a Flink job) out from
> {{TableEnvironmentImpl}} and put it close to the corresponding operation.
> This is how Spark does with {{RunnableCommand}} and {{V2CommandExec}}. In
> this way, we only need to add a new class of {{Operation}} without modifying
> {{TableEnvironmentImpl}} to support a new command.
> This is just an internal refactoring that doesn't affect user APIs and is
> backward-compatible.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)