KurtYoung commented on a change in pull request #8844: 
[FLINK-12951][table-planner] Add logic to bridge DDL to table source(…
URL: https://github.com/apache/flink/pull/8844#discussion_r300300764
 
 

 ##########
 File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/TableEnvironment.java
 ##########
 @@ -289,6 +289,69 @@
        @Deprecated
        String[] getCompletionHints(String statement, int position);
 
+       /**
+        * Evaluates single sql statement including DDLs and DMLs.
+        *
+        * <p>Note: Always use this interface to execute a sql query. It only 
supports
+        * to execute one sql statement a time.
+        *
+        * <p>A DDL statement can execute to create/drop a table/view:
+        * For example, the below DDL statement would create a CSV table named 
`tbl1`
+        * into the current catalog:
+        * <blockquote><pre>
+        *   create table tbl1(
+        *     a int,
+        *     b bigint,
+        *     c varchar
+        *   ) with (
+        *     connector = 'csv',
+        *     csv.path = 'xxx'
+        *   )
+        * </pre></blockquote>
+        *
+        * <p>The returns table format for different kind of statement:
+        * <ul>
+        *   <li>DDL: a table with one column of VARCHAR type to describe if 
this operation
+        *   is success.</li>
+        *   <li>DML: a sql insert returns a table with one column of VARCHAR 
type to describe the
+        *   affected rows; a sql query(select) returns a table to describe the 
query data set,
+        *   it can be further queried through the Table API, or directly write 
to sink with
+        *   {@link #insertInto(Table, String, String...)}.</li>
+        * </ul>
+        *
+        * <p>SQL queries can directly execute as follows:
+        *
+        * <blockquote><pre>
+        *   String sinkDDL = "create table sinkTable(
+        *                       a int,
+        *                       b varchar
+        *                     ) with (
+        *                       connector = 'csv',
+        *                       csv.path = 'xxx'
+        *                     )";
+        *
+        *  String sourceDDL ="create table sourceTable(
+        *                       a int,
+        *                       b varchar
+        *                     ) with (
+        *                       connector = 'kafka',
+        *                       kafka.topic = 'xxx',
+        *                       kafka.endpoint = 'x.x.x'
+        *                     )";
+        *
+        *  String query = "INSERT INTO sinkTable SELECT * FROM sourceTable";
+        *
+        *  tEnv.sql(sourceDDL);
+        *  tEnv.sql()sinkDDL);
 
 Review comment:
   sql(sinkDDL)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to