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 9E2F2200C1E for ; Fri, 17 Feb 2017 08:33:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9CA53160B3F; Fri, 17 Feb 2017 07:33:47 +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 EC8A4160B6D for ; Fri, 17 Feb 2017 08:33:46 +0100 (CET) Received: (qmail 27150 invoked by uid 500); 17 Feb 2017 07:33:46 -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 27011 invoked by uid 99); 17 Feb 2017 07:33:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Feb 2017 07:33:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 7ED061A090E for ; Fri, 17 Feb 2017 07:33:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id bebnK5Qg96Kr for ; Fri, 17 Feb 2017 07:33:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id A3B6F5F4AC for ; Fri, 17 Feb 2017 07:33:43 +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 AB1C6E0146 for ; Fri, 17 Feb 2017 07:33:42 +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 B6B3E24125 for ; Fri, 17 Feb 2017 07:33:41 +0000 (UTC) Date: Fri, 17 Feb 2017 07:33:41 +0000 (UTC) From: "Zhuoluo Yang (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (FLINK-5826) UDF/UDTF should support variable types and variable arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 17 Feb 2017 07:33:47 -0000 [ https://issues.apache.org/jira/browse/FLINK-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15871338#comment-15871338 ] Zhuoluo Yang edited comment on FLINK-5826 at 2/17/17 7:33 AM: -------------------------------------------------------------- I have already made a small modification in {code}UserDefinedFunctionUtils.getSignature(){code}. The basic idea is that we let the "Object..." and "Any*" pass and return the corresponding signature. This modification works for Java only. The Scala will fail. Since the code generation is to generate a Java codes, There will be some problem call {code} eval(Seq) {code} in generated Java. However, there will be no problem at all in calling {code}eval(Object... args}{code} in generated Java. was (Author: clarkyzl): I have already made a small modification in {code}UserDefinedFunctionUtils.getSignature(){code}. The basic idea is that we let the "Object..." and "Any*" pass and return the corresponding signature. This modification works for Java only. The Scala will fail. Since the code generation is to generate a Java codes, There will be some problem call {code} eval(Seq) {/code} in generated Java. However, there will be no problem at all in calling {code}eval(Object... args}{code} in generated Java. > UDF/UDTF should support variable types and variable arguments > ------------------------------------------------------------- > > Key: FLINK-5826 > URL: https://issues.apache.org/jira/browse/FLINK-5826 > Project: Flink > Issue Type: Improvement > Reporter: Zhuoluo Yang > Assignee: Zhuoluo Yang > > In some cases, UDF/UDTF should support variable types and variable arguments. Many UDF/UDTF developers wish to make the # of arguments and types flexible to users. They try to make their functions flexible. > Thus, we should support the following styles of UDF/UDTFs. > for example 1, in Java > {code:java} > public class SimpleUDF extends ScalarFunction { > public int eval(Object... args) { > // do something > } > } > {code} > for example 2, in Scala > {code} > class SimpleUDF extends ScalarFunction { > def eval(args: Any*): Int = { > // do something > } > } > {code} > If we modify the code in UserDefinedFunctionUtils.getSignature() and make both signatures pass. The first example will work normally. However, the second example will raise an exception. > {noformat} > Caused by: org.codehaus.commons.compiler.CompileException: Line 58, Column 0: No applicable constructor/method found for actual parameters "java.lang.String"; candidates are: "public java.lang.Object test.SimpleUDF.eval(scala.collection.Seq)" > at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:11523) ~[janino-3.0.6.jar:?] > at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:8679) ~[janino-3.0.6.jar:?] > at org.codehaus.janino.UnitCompiler.findIMethod(UnitCompiler.java:8539) ~[janino-3.0.6.jar:?] > {noformat} > The reason is that Scala will do a sugary modification to the signature of the method. The mothod {code} def eval(args: Any*){code} will become {code}def eval(args: scala.collection.Seq){code} in the class file. > The code generation has been done in Java. If we use java style {code}eval(Object... args){code} to call the Scala method, it will raise the above exception. > However, I can't always restrict users to use Java to write a UDF/UDTF. Any ideas in variable types and variable arguments of Scala UDF/UDTFs to prevent the compilation failure? -- This message was sent by Atlassian JIRA (v6.3.15#6346)