You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "xzw0223 (Jira)" <ji...@apache.org> on 2023/03/17 07:27:00 UTC

[jira] [Commented] (FLINK-31494) Introduce OperationExecutor for SqlToOperationConverter

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

xzw0223 commented on FLINK-31494:
---------------------------------

[~jark]  [~luoyuxia]  Is this the expected effect? I don’t know if there is any problem with my understanding. Please point it out.

> Introduce OperationExecutor for SqlToOperationConverter
> -------------------------------------------------------
>
>                 Key: FLINK-31494
>                 URL: https://issues.apache.org/jira/browse/FLINK-31494
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table SQL / Planner
>            Reporter: xzw0223
>            Priority: Major
>
> Introduce OperationExecutor for SqlToOperationConverter, following Timo's idea in FLINK-31368
> class like:
> {code:java}
> public interface OperationExecutor{  
> // The Operation supported by the current OperationExecutor 
> Class<? extends Operation> supportedOperation(); 
> // The SqlNode type supported by the current OperationExecutor 
> Class<? extends SqlNode> supportedSqlNode(); 
> // OperationExecutor is used to convert the validated sqlNode into Operation 
> Operation execute(SqlNode validated); 
> } {code}
>  
> Add an OperationExecutors to manage all OperationExecutors and be responsible for performing conversion sqlNode.
>  
> {code:java}
> public class OperationExecutors{
> private static Map<Class<? extends SqlNode>,OperationExecutor > executors = new HashMap<>();
>  static{ 
>     addExecutor(SqlCreateCatalog.class,CreateCatalogExecutor.class); 
>     // ..... 
>  }
>  private static void addExecutor(sqlnodeClass,operationExecutorsClass){             executors.put(sqlnodeClass,operationExecutorsClass.newInstance);
>  } 
>  public  OperationExecutor getExecutor(sqlnodeClass){
>  return executors.get(validated.getClass()); 
>  }
>  public Operation execute(SqlNode validated){
>  return executors.get(validated.getClass()).executor(validated); 
>  }
> } {code}
>  
> This can be used in SqlToOperationConverter.java 
> {code:java}
> private static Optional<Operation> convertValidatedSqlNode(
> FlinkPlannerImpl flinkPlanner, CatalogManager catalogManager, SqlNode validated) {
> OperationExecutor<?> executor = OperationExecutors.getExecutor(validated);
> if (executor == null){
>  return Optional.empty(); 
> }
> Operation operation = executor.execute(validated);
> if (operation!=null){
>  return Optional.of(operation); 
>  }
> }
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)