[jira] [Commented] (ASTERIXDB-1901) UDF fails at constant parameter

2017-05-11 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16007479#comment-16007479
 ] 

ASF subversion and git services commented on ASTERIXDB-1901:


Commit bacf0c595eb0172522ce88a2600a6deaaafbc98b in asterixdb's branch 
refs/heads/master from [~idleft]
[ https://git-wip-us.apache.org/repos/asf?p=asterixdb.git;h=bacf0c5 ]

ASTERIXDB-1901 Fix IntroduceDynamicTypeCastForExternalFunctionRule

1. Instead of pattern matching, now we will inspect every paramter of
   UDF. If there is a type mismatch, a cast function will be added.
2. Fixed the issue that type casting only applies to the first argument.
3. Added test case for this.

Change-Id: I6f44b2460ae3322fc52451e7939b6b5e711790a7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1730
Reviewed-by: Yingyi Bu 
Sonar-Qube: Jenkins 
Tested-by: Jenkins 


> 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)


[jira] [Commented] (ASTERIXDB-1901) UDF fails at constant parameter

2017-05-06 Thread Xikui Wang (JIRA)

[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15999614#comment-15999614
 ] 

Xikui Wang commented on ASTERIXDB-1901:
---

[~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
> };
> testlib#toUpper({"id":1, "text":"lower text"})
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ASTERIXDB-1901) UDF fails at constant parameter

2017-05-06 Thread Yingyi Bu (JIRA)

[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15999606#comment-15999606
 ] 

Yingyi Bu commented on ASTERIXDB-1901:
--

[~idleft]  where is your defined type TextType used?

1. The compiler tries to get everything as closed as possible.  
2. What's the query plan?  

> 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
> };
> testlib#toUpper({"id":1, "text":"lower text"})
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (ASTERIXDB-1901) UDF fails at constant parameter

2017-05-06 Thread Xikui Wang (JIRA)

[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15999597#comment-15999597
 ] 

Xikui Wang commented on ASTERIXDB-1901:
---

[~buyingyi] Hi Yingyi, I located where the problem is, but the fix is not quite 
clear to me. Could you give me some suggestions?

The exception happens because the constant record {"id":1, "text":"lower text"} 
has a closed datatype which causes the record type inconsistency in setting the 
parameter value (an open datatype is expected here). The 
IntroduceDynamicTypeCastForExternalFunctionRule finds possible type casting 
when the parameter is a variable. In this constant parameter case, parameter is 
a field of the function call, but not the parent... Thus I couldn't follow the 
existed method to handle this situation. Probably this should be handled in 
ConstantFoldingRule?  

> 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
> };
> testlib#toUpper({"id":1, "text":"lower text"})
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)