[ 
https://issues.apache.org/jira/browse/FLINK-10973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701447#comment-16701447
 ] 

ASF GitHub Bot commented on FLINK-10973:
----------------------------------------

sunjincheng121 commented on a change in pull request #7167: [FLINK-10973] 
[table] Add support for map to table API
URL: https://github.com/apache/flink/pull/7167#discussion_r236949507
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/batch/table/MapITCase.scala
 ##########
 @@ -0,0 +1,120 @@
+/*
+ * 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 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.batch.table
+
+import org.apache.flink.api.scala._
+import org.apache.flink.api.scala.util.CollectionDataSets
+import org.apache.flink.table.api.TableEnvironment
+import org.apache.flink.table.api.scala._
+import org.apache.flink.table.expressions.utils.{Func1, MapFunc1, MapFunc2, 
MapFunc3}
+import 
org.apache.flink.table.runtime.utils.TableProgramsTestBase.TableConfigMode
+import org.apache.flink.table.runtime.utils.{StreamITCase, 
TableProgramsClusterTestBase}
+import org.apache.flink.test.util.MultipleProgramsTestBase.TestExecutionMode
+import org.apache.flink.test.util.TestBaseUtils
+import org.junit.Assert.assertEquals
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+import org.junit.{Ignore, Test}
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable
+
+@RunWith(classOf[Parameterized])
+class MapITCase(
+    mode: TestExecutionMode,
+    configMode: TableConfigMode)
+  extends TableProgramsClusterTestBase(mode, configMode) {
+
+  @Test
+  def testSimpleMap(): Unit = {
+
+    val env: ExecutionEnvironment = 
ExecutionEnvironment.getExecutionEnvironment
+    val tEnv = TableEnvironment.getTableEnvironment(env, config)
+    StreamITCase.testResults = mutable.MutableList()
+
+    val ds = CollectionDataSets.getSmall3TupleDataSet(env).toTable(tEnv, 'a, 
'b, 'c)
+      .map(MapFunc1('a, 'b, 'c))
+
+    val results = ds.collect()
+
+    val expected = mutable.MutableList(
+      "star,1,1,Hi",
+      "star,2,2,Hello",
+      "star,3,2,Hello world").mkString("\n")
+    TestBaseUtils.compareResultAsText(results.asJava, expected)
+  }
+
+  @Test
+  def testScalarResult(): Unit = {
+
+    val env: ExecutionEnvironment = 
ExecutionEnvironment.getExecutionEnvironment
+    val tEnv = TableEnvironment.getTableEnvironment(env, config)
+    StreamITCase.testResults = mutable.MutableList()
+
+    val ds = CollectionDataSets.getSmall3TupleDataSet(env).toTable(tEnv, 'a, 
'b, 'c)
+      .map(Func1('a))
+
+    val results = ds.collect()
+
+    val expected = mutable.MutableList(
+      "2",
+      "3",
+      "4").mkString("\n")
+    TestBaseUtils.compareResultAsText(results.asJava, expected)
+  }
+
+  @Test
+  def testMultiMap(): Unit = {
+
+    val env: ExecutionEnvironment = 
ExecutionEnvironment.getExecutionEnvironment
+    val tEnv = TableEnvironment.getTableEnvironment(env, config)
+    StreamITCase.testResults = mutable.MutableList()
+
+    val ds = CollectionDataSets.getSmall3TupleDataSet(env).toTable(tEnv, 'a, 
'b, 'c)
+      .map(MapFunc1('a, 'b, 'c))
+      .map(MapFunc2('_c0, '_c1, '_c2, '_c3))
+
+    val results = ds.collect()
+
+    val expected = mutable.MutableList(
+      "star,2,1,Hi",
+      "star,3,2,Hello",
+      "star,4,2,Hello world").mkString("\n")
+    TestBaseUtils.compareResultAsText(results.asJava, expected)
+  }
+
+  @Ignore("This test is disabled because of: 
https://issues.apache.org/jira/browse/FLINK-10834"; +
+            "and will be opened after FLINK-10834 is fixed.")
+  @Test
 
 Review comment:
   @Ignore("Will be open when FLINK-10834 has been fixed.") ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add Map operator to Table API
> -----------------------------
>
>                 Key: FLINK-10973
>                 URL: https://issues.apache.org/jira/browse/FLINK-10973
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: sunjincheng
>            Assignee: Dian Fu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.8.0
>
>
> Add Map operator to Table API as described in [Google 
> doc|https://docs.google.com/document/d/1tnpxg31EQz2-MEzSotwFzqatsB4rNLz0I-l_vPa5H4Q/edit#heading=h.q23rny2iglsr]
> The usageļ¼š
> {code:java}
> val res = tab
>    .map(fun: ScalarFunction)  // output has columns 'a, 'b, 'c
>    .select('a, 'c)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to