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

sunjincheng commented on FLINK-11067:
-------------------------------------

Hi [~twalthr] thanks for redefining the current JIRA.'s goals! So, Currently we 
only extract the tableEnvironment interfaces, and do not unified the 
environment, right?

If so, i want share my thoughts as follows:

We can split the API from implementation with three TableEnvironment interfaces.
 * BaseTableEnvironment - will define java and scala public methods that are 
independent of type extraction
 * java.TableEnvironment - Method of extracting types in java mode.
 * scala.TableEnvironment - Method of extracting types in scala mode.

All implementations are moved into the TableEnvironmentImpl classes. 

The definition as follows:
 * BaseTableEnviroment(api-java)

       BaseTableEnvironment will define JAVA and SCALA public methods that are 
independent of type extraction.
{code:java}
public interface BaseTableEnvironment {

  ...

  void registerFunction(String name, ScalarFunction function);

  void registerTable(String name, Table table);

  void registerTableSource(String name, TableSource<?> tableSource);

  void registerTableSink(String name, TableSink<?> tableSink);

  ...

}{code}
 * TableEnviroment(api-java) - Method of extracting types in java mode.

{code:java}
public interface TableEnvironment extends BaseTableEnvironment {
…
<T> void registerFunction(String name, TableFunction<T> function);

<T, ACC> void registerFunction(

        String name, AggregateFunction<T, ACC> aggregateFunc);
...
}{code}
 * TableEnviroment(api-scala) - Method of extracting types in scala mode.

{code:java}
public interface TableEnvironment extends BaseTableEnvironment {
…

def registerFunction[T: TypeInformation](name: String, tf: TableFunction[T]): 
Unit

def registerFunction[T: TypeInformation, ACC: TypeInformation](

  name: String,f: AggregateFunction[T, ACC]): Unit

...
}{code}
All implementations are moved into the TableEnvironmentImpl classes. 

For a  specific Environment, such as scala.StreamTableEnvironment, it extends 
api.StreamTableEnvironmentImpl and implements scala.TableEnvironment. The code 
looks like as follows:
{code:java}
// scala.StreamTableEnvironment

class StreamTableEnvironment(
     execEnv: StreamExecutionEnvironment,
     config: TableConfig)
   extends org.apache.flink.table.api.StreamTableEnvironmentImpl(
         execEnv.getWrappedStreamExecutionEnvironment,
         config)
      with org.apache.flink.table.api.scala.TableEnvironment {

 ...
}{code}
What do you think?

> Convert TableEnvironments to interfaces
> ---------------------------------------
>
>                 Key: FLINK-11067
>                 URL: https://issues.apache.org/jira/browse/FLINK-11067
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API &amp; SQL
>            Reporter: Timo Walther
>            Priority: Major
>
> A more detailed description can be found in 
> [FLIP-32|https://cwiki.apache.org/confluence/display/FLINK/FLIP-32%3A+Restructure+flink-table+for+future+contributions].
> This task includes porting {{TableEnvironment}}, {{StreamTableEnvironment}}, 
> {{BatchTableEnvironment}} to Java interfaces. API-breaking changes should not 
> be necessary anymore as they should have been resolved by sibling issues. 
> Some refactoring and clean up might be necessary.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to