You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Xikui Wang (JIRA)" <ji...@apache.org> on 2017/05/06 22:33:04 UTC
[jira] [Comment Edited] (ASTERIXDB-1901) UDF fails at constant
parameter
[ https://issues.apache.org/jira/browse/ASTERIXDB-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15999614#comment-15999614 ]
Xikui Wang edited comment on ASTERIXDB-1901 at 5/6/17 10:32 PM:
----------------------------------------------------------------
[~buyingyi] During the function evaluation, JavaFunctionHelper will assign the input value to an arguments list for external UDF evaluation. The defined type is used as the expected type for the arguments (org/apache/asterix/external/library/JavaFunctionHelper.java:113). I think the ConstantFoldingRule triggers the evaluation.
Here are the logical plan before logical rewrite, the queries used in both cases are updated in the description:
{noformat}
-- Exception case before Logical Rewrite
distribute result [%0->$$0] -- |UNPARTITIONED|
project ([$$0]) -- |UNPARTITIONED|
assign [$$0] <- [function-call: externallibtest:testlib#toUpper, Args:[function-call: asterix:open-object-constructor, Args:[AString: {id}, AInt64: {1}, AString: {text}, AString: {lower text}]]] -- |UNPARTITIONED|
empty-tuple-source -- |UNPARTITIONED|
-- Succ case before Logical Rewrite
distribute result [%0->$$2] -- |UNPARTITIONED|
project ([$$2]) -- |UNPARTITIONED|
assign [$$2] <- [function-call: externallibtest:testlib#toUpper, Args:[%0->$$0]] -- |UNPARTITIONED|
assign [$$0] <- [function-call: asterix:open-object-constructor, Args:[AString: {id}, AInt64: {1}, AString: {text}, AString: {lower text}]] -- |UNPARTITIONED|
empty-tuple-source -- |UNPARTITIONED|
{noformat}
was (Author: idleft):
[~buyingyi] During the function evaluation, JavaFunctionHelper will assign the input value to an arguments list for external UDF evaluation. The defined type is used as the expected type for the arguments (org/apache/asterix/external/library/JavaFunctionHelper.java:113). I think the ConstantFoldingRule triggers the evaluation. Here are the logical plan before logical rewrite, the queries used in both cases are updated in the description:
{noformat}
-- Exception case before Logical Rewrite
distribute result [%0->$$0] -- |UNPARTITIONED|
project ([$$0]) -- |UNPARTITIONED|
assign [$$0] <- [function-call: externallibtest:testlib#toUpper, Args:[function-call: asterix:open-object-constructor, Args:[AString: {id}, AInt64: {1}, AString: {text}, AString: {lower text}]]] -- |UNPARTITIONED|
empty-tuple-source -- |UNPARTITIONED|
-- Succ case before Logical Rewrite
distribute result [%0->$$2] -- |UNPARTITIONED|
project ([$$2]) -- |UNPARTITIONED|
assign [$$2] <- [function-call: externallibtest:testlib#toUpper, Args:[%0->$$0]] -- |UNPARTITIONED|
assign [$$0] <- [function-call: asterix:open-object-constructor, Args:[AString: {id}, AInt64: {1}, AString: {text}, AString: {lower text}]] -- |UNPARTITIONED|
empty-tuple-source -- |UNPARTITIONED|
{noformat}
> UDF fails at constant parameter
> -------------------------------
>
> Key: ASTERIXDB-1901
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-1901
> Project: Apache AsterixDB
> Issue Type: Bug
> Reporter: Xikui Wang
> Assignee: Xikui Wang
>
> If the declared datatype for UDF input is a open type, UDF will fail when given constant record (which has a closed datatype implicitly)
> Execute following query with default lib installed can reproduce this issue:
> {noformat}
> drop dataverse externallibtest if exists;
> create dataverse externallibtest;
> use dataverse externallibtest;
> create type TextType if not exists as open {
> id: int32,
> text: string
> };
> /* This will fail */
> let $i:=testlib#toUpper({"id":1, "text":"lower text"})
> return $i
> /* This works */
> let $i:={"id":1, "text":"lower text"}
> return testlib#toUpper($i)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)