dawidwys commented on a change in pull request #8050: [FLINK-11067][table] 
Convert TableEnvironments to interfaces
URL: https://github.com/apache/flink/pull/8050#discussion_r276212755
 
 

 ##########
 File path: 
flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/api/java/BatchTableEnvironment.java
 ##########
 @@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.api.java;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.java.DataSet;
+import org.apache.flink.api.java.ExecutionEnvironment;
+import org.apache.flink.table.api.BatchQueryConfig;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.descriptors.BatchTableDescriptor;
+import org.apache.flink.table.descriptors.ConnectorDescriptor;
+import org.apache.flink.table.functions.AggregateFunction;
+import org.apache.flink.table.functions.TableFunction;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * The {@link TableEnvironment} for a Java batch {@link ExecutionEnvironment} 
that works
+ * with {@link DataSet}s.
+ *
+ * <p>A TableEnvironment can be used to:
+ * <ul>
+ *     <li>convert a {@link DataSet} to a {@link Table}</li>
+ *     <li>register a {@link DataSet} in the {@link TableEnvironment}'s 
catalog</li>
+ *     <li>register a {@link Table} in the {@link TableEnvironment}'s 
catalog</li>
+ *     <li>scan a registered table to obtain a {@link Table}</li>
+ *     <li>specify a SQL query on registered tables to obtain a {@link 
Table}</li>
+ *     <li>convert a {@link Table} into a {@link DataSet}</li>
+ *     <li>explain the AST and execution plan of a {@link Table}</li>
+ * </ul>
+ */
+@PublicEvolving
+public interface BatchTableEnvironment extends TableEnvironment {
+
+       /**
+        * Registers a {@link TableFunction} under a unique name in the 
TableEnvironment's catalog.
+        * Registered functions can be referenced in Table API and SQL queries.
+        *
+        * @param name The name under which the function is registered.
+        * @param tableFunction The TableFunction to register.
+        * @param <T> The type of the output row.
+        */
+       <T> void registerFunction(String name, TableFunction<T> tableFunction);
+
+       /**
+        * Registers an {@link AggregateFunction} under a unique name in the 
TableEnvironment's catalog.
+        * Registered functions can be referenced in Table API and SQL queries.
+        *
+        * @param name The name under which the function is registered.
+        * @param aggregateFunction The AggregateFunction to register.
+        * @param <T> The type of the output value.
+        * @param <ACC> The type of aggregate accumulator.
+        */
+       <T, ACC> void registerFunction(String name, AggregateFunction<T, ACC> 
aggregateFunction);
+
+       /**
+        * Converts the given {@link DataSet} into a {@link Table}.
+        *
+        * <p>The field names of the {@link Table} are automatically derived 
from the type of the
+        * {@link DataSet}.
+        *
+        * @param dataSet The {@link DataSet} to be converted.
+        * @tparam T The type of the {@link DataSet}.
+        * @return The converted {@link Table}.
+        */
+       <T> Table fromDataSet(DataSet<T> dataSet);
+
+       /**
+        * Converts the given {@link DataSet} into a {@link Table} with 
specified field names.
+        *
+        * Example:
+        *
+        * {{{
+        *   DataSet<Tuple2<String, Long>> set = ...
+        *   Table tab = tableEnv.fromDataSet(set, "a, b");
+        * }}}
+        *
+        * @param dataSet The {@link DataSet} to be converted.
+        * @param fields The field names of the resulting {@link Table}.
+        * @tparam T The type of the {@link DataSet}.
+        * @return The converted {@link Table}.
+        */
+       <T> Table fromDataSet(DataSet<T> dataSet, String fields);
+
+       /**
+        * Registers the given {@link DataSet} as table in the
+        * {@link TableEnvironment}'s catalog.
+        * Registered tables can be referenced in SQL queries.
+        *
+        * The field names of the {@link Table} are automatically derived from 
the type of the{@link DataSet}.
+        *
+        * @param name The name under which the {@link DataSet} is registered 
in the catalog.
+        * @param dataSet The {@link DataSet} to register.
+        * @tparam T The type of the {@link DataSet} to register.
+        */
+       <T> void registerDataSet(String name, DataSet<T> dataSet);
+
+       /**
+        * Registers the given {@link DataSet} as table with specified field 
names in the
+        * {@link TableEnvironment}'s catalog.
+        * Registered tables can be referenced in SQL queries.
+        *
+        * Example:
+        *
+        * {{{
 
 Review comment:
   Convert to javadoc

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to