Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4EF8E200D17 for ; Wed, 30 Aug 2017 21:52:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4D88D169DBA; Wed, 30 Aug 2017 19:52:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8BBA8169DB7 for ; Wed, 30 Aug 2017 21:52:09 +0200 (CEST) Received: (qmail 28974 invoked by uid 500); 30 Aug 2017 19:52:08 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 28565 invoked by uid 99); 30 Aug 2017 19:52:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2017 19:52:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 893D11826F3 for ; Wed, 30 Aug 2017 19:52:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id gYrCWgUSHoSu for ; Wed, 30 Aug 2017 19:52:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id CAA126102B for ; Wed, 30 Aug 2017 19:52:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 37C42E0E2B for ; Wed, 30 Aug 2017 19:52:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id D3A3124177 for ; Wed, 30 Aug 2017 19:52:02 +0000 (UTC) Date: Wed, 30 Aug 2017 19:52:02 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: =?utf-8?Q?[jira]_[Commented]_(FLINK-6442)_Extend_TableAPI_Support?= =?utf-8?Q?_Sink_Table_Registration_and?= =?utf-8?Q?_=E2=80=98insert_into=E2=80=99_Clause_in_SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 30 Aug 2017 19:52:10 -0000 [ https://issues.apache.org/jira/browse/FLINK-6442?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1614= 7920#comment-16147920 ]=20 ASF GitHub Bot commented on FLINK-6442: --------------------------------------- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/3829#discussion_r136104550 =20 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/t= able/api/BatchTableEnvironment.scala --- @@ -106,6 +106,43 @@ abstract class BatchTableEnvironment( } =20 /** + * Registers an external [[TableSink]] in this [[TableEnvironment]]= 's catalog. + * Registered sink tables can be referenced in SQL DML clause. + * + * Examples: + * + * - predefine a table sink with schema --- End diff -- =20 I think we should not require users to correctly configure the field na= mes and types of the table sink before registering it. We can configure it ourselves: =20 ``` val tableSink: TableSink =3D ... val fieldNames: Array[String] =3D Array("a", "b", "c") val fieldTypes: Array[TypeInformation[_]] =3D Array(Types.INT, Types.L= ONG, Types.STRING) =20 tableEnv.registerTableSink("example_sink_table", fieldNames, fieldTypes= , tableSink) ``` > Extend TableAPI Support Sink Table Registration and =E2=80=98insert into= =E2=80=99 Clause in SQL > -------------------------------------------------------------------------= ------ > > Key: FLINK-6442 > URL: https://issues.apache.org/jira/browse/FLINK-6442 > Project: Flink > Issue Type: New Feature > Components: Table API & SQL > Reporter: lincoln.lee > Assignee: lincoln.lee > Priority: Minor > > Currently in TableAPI there=E2=80=99s only registration method for sourc= e table, when we use SQL writing a streaming job, we should add additional= part for the sink, like TableAPI does: > {code} > val sqlQuery =3D "SELECT * FROM MyTable WHERE _1 =3D 3" > val t =3D StreamTestData.getSmall3TupleDataStream(env) > tEnv.registerDataStream("MyTable", t) > // one way: invoke tableAPI=E2=80=99s writeToSink method directly > val result =3D tEnv.sql(sqlQuery) > result.writeToSink(new YourStreamSink) > // another way: convert to datastream first and then invoke addSink=20 > val result =3D tEnv.sql(sqlQuery).toDataStream[Row] > result.addSink(new StreamITCase.StringSink) > {code} > From the api we can see the sink table always be a derived table because = its 'schema' is inferred from the result type of upstream query. > Compare to traditional RDBMS which support DML syntax, a query with a tar= get output could be written like this: > {code} > insert into table target_table_name > [(column_name [ ,...n ])] > query > {code} > The equivalent form of the example above is as follows: > {code} > tEnv.registerTableSink("targetTable", new YourSink) > val sql =3D "INSERT INTO targetTable SELECT a, b, c FROM sourceTable" > val result =3D tEnv.sql(sql) > {code} > It is supported by Calcite=E2=80=99s grammar:=20 > {code} > insert:( INSERT | UPSERT ) INTO tablePrimary > [ '(' column [, column ]* ')' ] > query > {code} > I'd like to extend Flink TableAPI to support such feature. see design do= c: https://goo.gl/n3phK5 -- This message was sent by Atlassian JIRA (v6.4.14#64029)