[ 
https://issues.apache.org/jira/browse/FLINK-31368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698429#comment-17698429
 ] 

Jark Wu commented on FLINK-31368:
---------------------------------

[~twalthr], thank you for your idea. Another idea is colocating the execution 
logic within the Operation, just like how RunnableCommand and V2CommandExec do 
in Spark. We can introduce a class like: 

{code:java}
public interface ExecutableOperation {

    TableResultInternal execute(Context ctx);

    interface Context {
        CatalogManager getCatalogManager();

        FunctionCatalog getFunctionCatalog();

        ResourceManager getResourceManager();

        Configuration getConfiguration();
    }
}
{code}

Many base interfaces can extends it ({{AlterOperation}}, {{CreateOperation}}, 
{{DropOperation}}, etc.). This approach improves code readability (not spread 
code across different classes) and makes supporting a new statement by just 
adding an Operation class instead of 3 classes (Operation class, Executor 
class, and the mapping class). 

What do you think about this?

> 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)

Reply via email to