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 26ECA200CC5 for ; Tue, 27 Jun 2017 04:43:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 25A01160BDE; Tue, 27 Jun 2017 02:43:05 +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 4528C160BDA for ; Tue, 27 Jun 2017 04:43:04 +0200 (CEST) Received: (qmail 8864 invoked by uid 500); 27 Jun 2017 02:43:03 -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 8854 invoked by uid 99); 27 Jun 2017 02:43:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Jun 2017 02:43:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 063FAC00A9 for ; Tue, 27 Jun 2017 02:43:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-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-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id xlY4sOGWC32f for ; Tue, 27 Jun 2017 02:43:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id D438A5F4EC for ; Tue, 27 Jun 2017 02:43:00 +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 554BFE09F4 for ; Tue, 27 Jun 2017 02:43:00 +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 0BC272411C for ; Tue, 27 Jun 2017 02:43:00 +0000 (UTC) Date: Tue, 27 Jun 2017 02:43:00 +0000 (UTC) From: "Fang Yong (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (FLINK-7010) Lamdba expression in flatMap throws InvalidTypesException in DataSet MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 27 Jun 2017 02:43:05 -0000 [ https://issues.apache.org/jira/browse/FLINK-7010?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fang Yong updated FLINK-7010: ----------------------------- Description: When I create an example and use lambda in flatMap as follows {noformat} ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet source = env.fromCollection( Lists.newArrayList("hello", "flink", "test", "flat", "map", "lambda")); DataSet> tupled = source.flatMap((word, out) -> { int length = word.length(); out.collect(Tuple2.of(length, word)); }); try { tupled.print(); } catch (Exception e) { throw new RuntimeException(e); } {noformat} InvalidTypesException was throwed and the exception stack is as follows: {noformat} Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The return type of function 'testFlatMap(FlatMapTest.java:20)' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface. at org.apache.flink.api.java.DataSet.getType(DataSet.java:178) at org.apache.flink.api.java.DataSet.collect(DataSet.java:407) at org.apache.flink.api.java.DataSet.print(DataSet.java:1605) Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The generic type parameters of 'Collector' are missing. It seems that your compiler has not stored them into the .class file. Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature type-safely. See the documentation for more information about how to compile jobs containing lambda expressions. at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameter(TypeExtractor.java:1653) at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameters(TypeExtractor.java:1639) at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:573) at org.apache.flink.api.java.typeutils.TypeExtractor.getFlatMapReturnTypes(TypeExtractor.java:188) at org.apache.flink.api.java.DataSet.flatMap(DataSet.java:266) {noformat} The 20th line code is {noformat} DataSet> tupled = source.flatMap((word, out) -> { {noformat} When I use FlatMapFunction instead of lambda, it will be all right was: When I create an example and use lambda in flatMap as follows {noformat} ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet source = env.fromCollection( Lists.newArrayList("hello", "flink", "test", "flat", "map", "lambda")); DataSet> tupled = source.flatMap((word, out) -> { int length = word.length(); out.collect(Tuple2.of(length, word)); }); try { tupled.print(); } catch (Exception e) { throw new RuntimeException(e); } {noformat} InvalidTypesException was throwed and the exception stack is as follows: {noformat} Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The return type of function 'testFlatMap(FlatMapTest.java:20)' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface. at org.apache.flink.api.java.DataSet.getType(DataSet.java:178) at org.apache.flink.api.java.DataSet.collect(DataSet.java:407) at org.apache.flink.api.java.DataSet.print(DataSet.java:1605) Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The generic type parameters of 'Collector' are missing. It seems that your compiler has not stored them into the .class file. Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature type-safely. See the documentation for more information about how to compile jobs containing lambda expressions. at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameter(TypeExtractor.java:1653) at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameters(TypeExtractor.java:1639) at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:573) at org.apache.flink.api.java.typeutils.TypeExtractor.getFlatMapReturnTypes(TypeExtractor.java:188) at org.apache.flink.api.java.DataSet.flatMap(DataSet.java:266) The 20th line code is {noformat} DataSet> tupled = source.flatMap((word, out) -> { {noformat} When I use FlatMapFunction instead of lambda, it will be all right > Lamdba expression in flatMap throws InvalidTypesException in DataSet > -------------------------------------------------------------------- > > Key: FLINK-7010 > URL: https://issues.apache.org/jira/browse/FLINK-7010 > Project: Flink > Issue Type: Bug > Reporter: Fang Yong > > When I create an example and use lambda in flatMap as follows > {noformat} > ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); > DataSet source = env.fromCollection( > Lists.newArrayList("hello", "flink", "test", "flat", "map", "lambda")); > DataSet> tupled = source.flatMap((word, out) -> { > int length = word.length(); > out.collect(Tuple2.of(length, word)); > }); > try { > tupled.print(); > } catch (Exception e) { > throw new RuntimeException(e); > } > {noformat} > InvalidTypesException was throwed and the exception stack is as follows: > {noformat} > Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The return type of function 'testFlatMap(FlatMapTest.java:20)' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface. > at org.apache.flink.api.java.DataSet.getType(DataSet.java:178) > at org.apache.flink.api.java.DataSet.collect(DataSet.java:407) > at org.apache.flink.api.java.DataSet.print(DataSet.java:1605) > Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The generic type parameters of 'Collector' are missing. > It seems that your compiler has not stored them into the .class file. > Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature type-safely. > See the documentation for more information about how to compile jobs containing lambda expressions. > at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameter(TypeExtractor.java:1653) > at org.apache.flink.api.java.typeutils.TypeExtractor.validateLambdaGenericParameters(TypeExtractor.java:1639) > at org.apache.flink.api.java.typeutils.TypeExtractor.getUnaryOperatorReturnType(TypeExtractor.java:573) > at org.apache.flink.api.java.typeutils.TypeExtractor.getFlatMapReturnTypes(TypeExtractor.java:188) > at org.apache.flink.api.java.DataSet.flatMap(DataSet.java:266) > {noformat} > The 20th line code is > {noformat} > DataSet> tupled = source.flatMap((word, out) -> { > {noformat} > When I use FlatMapFunction instead of lambda, it will be all right -- This message was sent by Atlassian JIRA (v6.4.14#64029)