[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860548
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/BatchTableEnvironment.scala
 ---
@@ -94,11 +95,12 @@ class BatchTableEnvironment(
 * @param name The name under which the [[DataSet]] is registered in 
the catalog.
 * @param dataSet The [[DataSet]] to register.
 * @tparam T The type of the [[DataSet]] to register.
+* @param replace whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860444
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/scala/BatchTableEnvironment.scala
 ---
@@ -53,12 +53,13 @@ class BatchTableEnvironment(
 *
 * @param dataSet The [[DataSet]] to be converted.
 * @tparam T The type of the [[DataSet]].
+* @param replace whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860789
  
--- Diff: 
flink-libraries/flink-table/src/test/java/org/apache/flink/table/runtime/batch/sql/JavaSqlITCase.java
 ---
@@ -71,8 +71,10 @@ public void testValues() throws Exception {
// Calcite converts to decimals and strings with equal 
length
"1,Test ,true,1944-02-24,12.4445\n";
compareResultAsText(results, expected);
+   
}
 
+
--- End diff --

remove blank line


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199858297
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -77,15 +90,38 @@ class BatchTableEnvironment(
 * @return The converted [[Table]].
 */
   def fromDataSet[T](dataSet: DataSet[T], fields: String): Table = {
+
--- End diff --

remove blank line


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857602
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/TableEnvironment.scala
 ---
@@ -415,6 +416,19 @@ abstract class TableEnvironment(val config: 
TableConfig) {
 */
   def registerTable(name: String, table: Table): Unit = {
 
+registerTable(name, table, false)
+  }
+
+  /**
+* Registers a [[Table]] under a unique name in the TableEnvironment's 
catalog.
+* Registered tables can be referenced in SQL queries.
+*
+* @param name The name under which the table will be registered.
+* @param table The table to register.
+* @param replace  Whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857801
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/TableEnvironment.scala
 ---
@@ -433,9 +447,24 @@ abstract class TableEnvironment(val config: 
TableConfig) {
 * @param nameThe name under which the [[TableSource]] is 
registered.
 * @param tableSource The [[TableSource]] to register.
 */
-  def registerTableSource(name: String, tableSource: TableSource[_]): Unit 
= {
+  def registerTableSource(name: String,
+  tableSource: TableSource[_]): Unit = {
+registerTableSource(name, tableSource, false)
+  }
+
+  /**
+* Registers an external [[TableSource]] in this [[TableEnvironment]]'s 
catalog.
+* Registered tables can be referenced in SQL queries.
+*
+* @param nameThe name under which the [[TableSource]] is 
registered.
+* @param tableSource The [[TableSource]] to register.
+* @param replace Whether to replace the registered table
--- End diff --

end with a point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860711
  
--- Diff: 
flink-libraries/flink-table/src/test/java/org/apache/flink/table/runtime/batch/sql/JavaSqlITCase.java
 ---
@@ -71,8 +71,10 @@ public void testValues() throws Exception {
// Calcite converts to decimals and strings with equal 
length
"1,Test ,true,1944-02-24,12.4445\n";
compareResultAsText(results, expected);
+   
--- End diff --

remove blank line


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199859899
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -77,15 +90,38 @@ class BatchTableEnvironment(
 * @return The converted [[Table]].
 */
   def fromDataSet[T](dataSet: DataSet[T], fields: String): Table = {
+
+fromDataSet(dataSet, fields, false)
+  }
+
+  /**
+* Converts the given [[DataSet]] into a [[Table]] with specified field 
names. And could
+* also replace the existing table if it is already registered.
+*
+* Example:
+*
+* {{{
+*   DataSet> set = ...
+*   Table tab = tableEnv.fromDataSet(set, "a, b", true)
+* }}}
+*
+* @param dataSet The [[DataSet]] to be converted.
+* @param fields The field names of the resulting [[Table]].
+* @tparam T The type of the [[DataSet]].
+* @param replace Whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199855960
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/BatchTableEnvironment.scala
 ---
@@ -95,15 +95,17 @@ abstract class BatchTableEnvironment(
 *
 * @param nameThe name under which the [[TableSource]] is 
registered.
 * @param tableSource The [[TableSource]] to register.
+* @param replace Whether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860344
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -118,15 +195,19 @@ class BatchTableEnvironment(
 * @param name The name under which the [[DataSet]] is registered in 
the catalog.
 * @param dataSet The [[DataSet]] to register.
 * @param fields The field names of the registered table.
+* @param replace Whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860044
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -95,12 +131,53 @@ class BatchTableEnvironment(
 *
 * @param name The name under which the [[DataSet]] is registered in 
the catalog.
 * @param dataSet The [[DataSet]] to register.
+* @param replace Whether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199858196
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -55,9 +55,22 @@ class BatchTableEnvironment(
 * @return The converted [[Table]].
 */
   def fromDataSet[T](dataSet: DataSet[T]): Table = {
+fromDataSet(dataSet, false)
+  }
 
+  /**
+* Converts the given [[DataSet]] into a [[Table]].
+*
+* The field names of the [[Table]] are automatically derived from the 
type of the [[DataSet]].
+*
+* @param dataSet The [[DataSet]] to be converted.
+* @tparam T The type of the [[DataSet]].
+* @param replace Whether to replace the registered table
--- End diff --

end with a point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857340
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/BatchTableEnvironment.scala
 ---
@@ -280,16 +284,19 @@ abstract class BatchTableEnvironment(
 * @param name The name under which the table is registered in the 
catalog.
 * @param dataSet The [[DataSet]] to register as table in the catalog.
 * @tparam T the type of the [[DataSet]].
+* @param replace Whether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857390
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/StreamTableEnvironment.scala
 ---
@@ -163,12 +164,14 @@ abstract class StreamTableEnvironment(
 * @param fieldNames The field names to register with the [[TableSink]].
 * @param fieldTypes The field types to register with the [[TableSink]].
 * @param tableSink The [[TableSink]] to register.
+* @param replace  Whether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199860145
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/java/BatchTableEnvironment.scala
 ---
@@ -95,12 +131,53 @@ class BatchTableEnvironment(
 *
 * @param name The name under which the [[DataSet]] is registered in 
the catalog.
 * @param dataSet The [[DataSet]] to register.
+* @param replace Whether to replace the registered table
 * @tparam T The type of the [[DataSet]] to register.
 */
   def registerDataSet[T](name: String, dataSet: DataSet[T]): Unit = {
 
+registerDataSet(name, dataSet, false)
+  }
+
+  /**
+* Registers the given [[DataSet]] as table in the
+* [[TableEnvironment]]'s catalog.
+* Registered tables can be referenced in SQL queries.
+*
+* The field names of the [[Table]] are automatically derived from the 
type of the [[DataSet]].
+*
+* @param name The name under which the [[DataSet]] is registered in 
the catalog.
+* @param dataSet The [[DataSet]] to register.
+* @param replace Whether to replace the registered table
--- End diff --

end with point.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857354
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/BatchTableEnvironment.scala
 ---
@@ -300,9 +307,10 @@ abstract class BatchTableEnvironment(
 * @param dataSet The [[DataSet]] to register as table in the catalog.
 * @param fields The field expressions to define the field names of the 
table.
 * @tparam T The type of the [[DataSet]].
+* @param replace Whether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857432
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/TableEnvironment.scala
 ---
@@ -415,6 +416,19 @@ abstract class TableEnvironment(val config: 
TableConfig) {
 */
   def registerTable(name: String, table: Table): Unit = {
 
+registerTable(name, table, false)
+  }
+
+  /**
+* Registers a [[Table]] under a unique name in the TableEnvironment's 
catalog.
--- End diff --

I think replace "under" to "with", would be better.


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-03 Thread yanghua
Github user yanghua commented on a diff in the pull request:

https://github.com/apache/flink/pull/6236#discussion_r199857321
  
--- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/BatchTableEnvironment.scala
 ---
@@ -145,12 +147,14 @@ abstract class BatchTableEnvironment(
 * @param fieldNames The field names to register with the [[TableSink]].
 * @param fieldTypes The field types to register with the [[TableSink]].
 * @param tableSink  The [[TableSink]] to register.
+* @param replaceWhether to replace the registered table
--- End diff --

end with point


---


[GitHub] flink pull request #6236: [FLINK-9699]. Add api to replace registered table

2018-07-02 Thread zjffdu
GitHub user zjffdu opened a pull request:

https://github.com/apache/flink/pull/6236

[FLINK-9699]. Add api to replace registered table

*Thank you very much for contributing to Apache Flink - we are happy that 
you want to help us improve Flink. To help the community review your 
contribution in the best possible way, please go through the checklist below, 
which will get the contribution into a shape in which it can be best reviewed.*

*Please understand that we do not do this to make contributions to Flink a 
hassle. In order to uphold a high standard of quality for code contributions, 
while at the same time managing a large number of contributions, we need 
contributors to prepare the contributions well, and give reviewers enough 
contextual information for the review. Please also understand that 
contributions that do not follow this guide will take longer to review and thus 
typically be picked up with lower priority by the community.*

## Contribution Checklist

  - Make sure that the pull request corresponds to a [JIRA 
issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are 
made for typos in JavaDoc or documentation files, which need no JIRA issue.
  
  - Name the pull request in the form "[FLINK-] [component] Title of 
the pull request", where *FLINK-* should be replaced by the actual issue 
number. Skip *component* if you are unsure about which is the best component.
  Typo fixes that have no associated JIRA issue should be named following 
this pattern: `[hotfix] [docs] Fix typo in event time introduction` or 
`[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.

  - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
  
  - Make sure that the change passes the automated tests, i.e., `mvn clean 
verify` passes. You can set up Travis CI to do that following [this 
guide](http://flink.apache.org/contribute-code.html#best-practices).

  - Each pull request should address only one issue, not mix up code from 
multiple issues.
  
  - Each commit in the pull request has a meaningful commit message 
(including the JIRA id)

  - Once all items of the checklist are addressed, remove the above text 
and this checklist, leaving only the filled out template below.


**(The sections below can be removed for hotfixes of typos)**

## What is the purpose of the change

*(For example: This pull request makes task deployment go through the blob 
server, rather than through RPC. That way we avoid re-transferring them on each 
deployment (during recovery).)*


## Brief change log

*(for example:)*
  - *The TaskInfo is stored in the blob store on job creation time as a 
persistent artifact*
  - *Deployments RPC transmits only the blob storage reference*
  - *TaskManagers retrieve the TaskInfo from the blob cache*


## Verifying this change

*(Please pick either of the following options)*

This change is a trivial rework / code cleanup without any test coverage.

*(or)*

This change is already covered by existing tests, such as *(please describe 
tests)*.

*(or)*

This change added tests and can be verified as follows:

*(example:)*
  - *Added integration tests for end-to-end deployment with large payloads 
(100MB)*
  - *Extended integration test for recovery after master (JobManager) 
failure*
  - *Added test that validates that TaskInfo is transferred only once 
across recoveries*
  - *Manually verified the change by running a 4 node cluser with 2 
JobManagers and 4 TaskManagers, a stateful streaming program, and killing one 
JobManager and two TaskManagers during the execution, verifying that recovery 
happens correctly.*

## Does this pull request potentially affect one of the following parts:

  - Dependencies (does it add or upgrade a dependency): (yes / no)
  - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (yes / no)
  - The serializers: (yes / no / don't know)
  - The runtime per-record code paths (performance sensitive): (yes / no / 
don't know)
  - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  - The S3 file system connector: (yes / no / don't know)

## Documentation

  - Does this pull request introduce a new feature? (yes / no)
  - If yes, how is the feature documented? (not applicable / docs / 
JavaDocs / not documented)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/zjffdu/flink FLINK-9699

Alternatively you can review and apply these changes as the patch at: