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 9A1AB200BA3 for ; Wed, 5 Oct 2016 16:53:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 98D31160AF9; Wed, 5 Oct 2016 14:53:23 +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 B2EDB160AF2 for ; Wed, 5 Oct 2016 16:53:22 +0200 (CEST) Received: (qmail 89189 invoked by uid 500); 5 Oct 2016 14:53:21 -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 88486 invoked by uid 99); 5 Oct 2016 14:53:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Oct 2016 14:53:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 4CD242C014E for ; Wed, 5 Oct 2016 14:53:21 +0000 (UTC) Date: Wed, 5 Oct 2016 14:53:21 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-4691) Add group-windows for streaming tables MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 05 Oct 2016 14:53:23 -0000 [ https://issues.apache.org/jira/browse/FLINK-4691?page=3Dcom.atlassian= .jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1554= 8971#comment-15548971 ]=20 ASF GitHub Bot commented on FLINK-4691: --------------------------------------- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/2562#discussion_r81851322 =20 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/a= pi/table/windows.scala --- @@ -0,0 +1,340 @@ +/* + * 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 imp= lied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.table + +import org.apache.flink.api.table.expressions.{Expression, ExpressionP= arser} +import org.apache.flink.api.table.plan.logical._ + +/** + * Group-window specification. Group-windows allow aggregates which a= re computed for a group of + * elements. A (time or row-count) window is required to bound the in= finite input stream into a + * finite group. Group-windows are evaluated once per group. + */ +trait GroupWindow { + + /** + * Converts an API class to a logical window for planning. This is = an internal method. + */ + private[flink] def toLogicalWindow: LogicalWindow +} + +/** + * A group-window operating on event-time. + * + * @param timeField defines the time mode for streaming tables and ac= ts as a time attribute for + * batch tables over which the query is evaluated. + */ +abstract class EventTimeWindow(timeField: Expression) extends GroupWin= dow { + + protected var name: Option[Expression] =3D None + + /** + * Assigns an alias for this window that the following `select()` c= lause can refer to in order + * to access window properties such as window start or end time. + * + * @param alias alias for this window + * @return this window + */ + def as(alias: Expression): EventTimeWindow =3D { + this.name =3D Some(alias) + this + } + + /** + * Assigns an alias for this window that the following `select()` c= lause can refer to in order + * to access window properties such as window start or end time. + * + * @param alias alias for this window + * @return this window + */ + def as(alias: String): EventTimeWindow =3D as(ExpressionParser.parse= Expression(alias)) +} + +// -------------------------------------------------------------------= ----------------------------- +// Tumbling group-windows +// -------------------------------------------------------------------= ----------------------------- + +/** + * Tumbling group-window. By default, it works on processing-time. + * + * @param size size of the window either as number of rows or interva= l of milliseconds + */ +class TumblingWindow(size: Expression) extends GroupWindow { + + /** + * Tumbling group-window. By default, it works on processing-time. + * + * @param size size of the window either as number of rows or inter= val of milliseconds + */ + def this(size: String) =3D this(ExpressionParser.parseExpression(siz= e)) + + private var alias: Option[Expression] =3D None + + /** + * Defines the time mode for streaming tables and specifies a time = attribute for --- End diff -- =20 Use event-time mode for streaming tables by calling with `on('rowtime)`= . > Add group-windows for streaming tables=09 > --------------------------------------- > > Key: FLINK-4691 > URL: https://issues.apache.org/jira/browse/FLINK-4691 > Project: Flink > Issue Type: Sub-task > Components: Table API & SQL > Reporter: Timo Walther > Assignee: Timo Walther > > Add Tumble, Slide, Session group-windows for streaming tables as describe= d in [FLIP-11|https://cwiki.apache.org/confluence/display/FLINK/FLIP-11%3A+= Table+API+Stream+Aggregations].=20 > Implementation of group-windows on streaming tables. This includes implem= enting the API of group-windows, the logical validation for group-windows, = and the definition of the =E2=80=9Crowtime=E2=80=9D and =E2=80=9Csystemtime= =E2=80=9D keywords. Group-windows on batch tables won=E2=80=99t be initiall= y supported and will throw an exception. -- This message was sent by Atlassian JIRA (v6.3.4#6332)