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 5602C2009F9 for ; Mon, 23 May 2016 16:30:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5512E160A0E; Mon, 23 May 2016 14:30:14 +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 21769160A2B for ; Mon, 23 May 2016 16:30:12 +0200 (CEST) Received: (qmail 75087 invoked by uid 500); 23 May 2016 14:30:12 -0000 Mailing-List: contact commits-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 commits@flink.apache.org Received: (qmail 75015 invoked by uid 99); 23 May 2016 14:30:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 May 2016 14:30:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D76D2DFDEF; Mon, 23 May 2016 14:30:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: fhueske@apache.org To: commits@flink.apache.org Date: Mon, 23 May 2016 14:30:12 -0000 Message-Id: <3c8ce930ed2c42438debee2863f63e66@git.apache.org> In-Reply-To: <7fffba6bdc824eaf8aef5d9cf8e6750a@git.apache.org> References: <7fffba6bdc824eaf8aef5d9cf8e6750a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] flink git commit: [hotfix] [tableAPI] Throw helpful exception for unsupported ORDER BY features. archived-at: Mon, 23 May 2016 14:30:14 -0000 [hotfix] [tableAPI] Throw helpful exception for unsupported ORDER BY features. Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/905ac6ed Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/905ac6ed Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/905ac6ed Branch: refs/heads/master Commit: 905ac6edacefac7bed780c86211df6950a2470d3 Parents: 173d24d Author: Fabian Hueske Authored: Mon May 23 14:03:16 2016 +0200 Committer: Fabian Hueske Committed: Mon May 23 14:03:16 2016 +0200 ---------------------------------------------------------------------- .../plan/rules/dataSet/DataSetSortRule.scala | 10 ++++++++ .../flink/api/scala/batch/sql/SortITCase.scala | 25 ++++++++++++++++++++ 2 files changed, 35 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/905ac6ed/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataSet/DataSetSortRule.scala ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataSet/DataSetSortRule.scala b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataSet/DataSetSortRule.scala index b7f70e3..b26d1de 100644 --- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataSet/DataSetSortRule.scala +++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/rules/dataSet/DataSetSortRule.scala @@ -23,6 +23,7 @@ import org.apache.calcite.rel.RelNode import org.apache.calcite.rel.convert.ConverterRule import org.apache.calcite.rel.core.JoinRelType import org.apache.calcite.rel.logical.{LogicalJoin, LogicalSort} +import org.apache.flink.api.table.TableException import org.apache.flink.api.table.plan.nodes.dataset.{DataSetConvention, DataSetSort} class DataSetSortRule @@ -37,6 +38,15 @@ class DataSetSortRule */ override def matches(call: RelOptRuleCall): Boolean = { val sort = call.rel(0).asInstanceOf[LogicalSort] + + if (sort.offset != null) { + throw new TableException("ORDER BY OFFSET is currently not supported.") + } + + if (sort.fetch != null) { + throw new TableException("ORDER BY FETCH is currently not supported.") + } + sort.offset == null && sort.fetch == null } http://git-wip-us.apache.org/repos/asf/flink/blob/905ac6ed/flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/SortITCase.scala ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/SortITCase.scala b/flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/SortITCase.scala index 0dea0b6a..7206be7 100644 --- a/flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/SortITCase.scala +++ b/flink-libraries/flink-table/src/test/scala/org/apache/flink/api/scala/batch/sql/SortITCase.scala @@ -25,6 +25,7 @@ import org.apache.flink.api.scala.batch.utils.SortTestUtils._ import org.apache.flink.api.scala.util.CollectionDataSets import org.apache.flink.api.scala.table._ import org.apache.flink.api.scala._ +import org.apache.flink.api.table.plan.PlanGenException import org.apache.flink.api.table.{Row, TableEnvironment} import org.apache.flink.test.util.MultipleProgramsTestBase.TestExecutionMode import org.apache.flink.test.util.TestBaseUtils @@ -60,4 +61,28 @@ class SortITCase( TestBaseUtils.compareOrderedResultAsText(result.asJava, expected) } + @Test(expected = classOf[PlanGenException]) + def testOrderByOffset(): Unit = { + val env = ExecutionEnvironment.getExecutionEnvironment + val tEnv = TableEnvironment.getTableEnvironment(env, config) + + val sqlQuery = "SELECT * FROM MyTable ORDER BY _1 OFFSET 2 ROWS" + + val ds = CollectionDataSets.get3TupleDataSet(env) + tEnv.registerDataSet("MyTable", ds) + tEnv.sql(sqlQuery).toDataSet[Row] + } + + @Test(expected = classOf[PlanGenException]) + def testOrderByFirst(): Unit = { + val env = ExecutionEnvironment.getExecutionEnvironment + val tEnv = TableEnvironment.getTableEnvironment(env, config) + + val sqlQuery = "SELECT * FROM MyTable ORDER BY _1 FETCH NEXT 2 ROWS ONLY" + + val ds = CollectionDataSets.get3TupleDataSet(env) + tEnv.registerDataSet("MyTable", ds) + tEnv.sql(sqlQuery).toDataSet[Row] + } + }