[ https://issues.apache.org/jira/browse/FLINK-10973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16698394#comment-16698394 ]
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_r236102599 ########## File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/runtime/stream/table/MapITCase.scala ########## @@ -0,0 +1,78 @@ +/* + * 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.stream.table + +import org.apache.flink.api.scala._ +import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment +import org.apache.flink.table.api.scala._ +import org.apache.flink.table.api.TableEnvironment +import org.apache.flink.table.expressions.utils.{MapFunc1, MapFunc2} +import org.apache.flink.table.runtime.utils.{StreamITCase, StreamTestData} +import org.apache.flink.test.util.AbstractTestBase +import org.apache.flink.types.Row +import org.junit.Assert.assertEquals +import org.junit.Test + +import scala.collection.mutable + +class MapITCase extends AbstractTestBase { + + @Test + def testSimpleMap(): Unit = { + + val env = StreamExecutionEnvironment.getExecutionEnvironment + val tEnv = TableEnvironment.getTableEnvironment(env) + StreamITCase.testResults = mutable.MutableList() + + val ds = StreamTestData.getSmall3TupleDataStream(env).toTable(tEnv, 'a, 'b, 'c) + .map(MapFunc1('a, 'b, 'c)) + + val results = ds.toAppendStream[Row] + results.addSink(new StreamITCase.StringSink[Row]) + env.execute() + + val expected = mutable.MutableList( + "star,1,1,Hi", + "star,2,2,Hello", + "star,3,2,Hello world") + assertEquals(expected.sorted, StreamITCase.testResults.sorted) + } + + @Test + def testMultiMap(): Unit = { + + val env = StreamExecutionEnvironment.getExecutionEnvironment + val tEnv = TableEnvironment.getTableEnvironment(env) + StreamITCase.testResults = mutable.MutableList() + + val ds = StreamTestData.getSmall3TupleDataStream(env).toTable(tEnv, 'a, 'b, 'c) + .map(MapFunc1('a, 'b, 'c)) + .map(MapFunc2('_c0, '_c1, '_c2, '_c3)) + + val results = ds.toAppendStream[Row] + results.addSink(new StreamITCase.StringSink[Row]) + env.execute() + + val expected = mutable.MutableList( + "star,2,1,Hi", + "star,3,2,Hello", + "star,4,2,Hello world") + assertEquals(expected.sorted, StreamITCase.testResults.sorted) + } +} Review comment: Add a non-deterministic scalar function test case. And add the reasons why can't produce the correct results. linked to [FLINK-10834](https://issues.apache.org/jira/browse/FLINK-10834) ---------------------------------------------------------------- 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)