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

ASF subversion and git services commented on ASTERIXDB-1204:
------------------------------------------------------------

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

ASTERIXDB-1204: fixed LIMIT pushdown into join

 - Added a test case

Change-Id: Id4bb09bddca64b26598d693d295fdc3ec9d63052
Reviewed-on: https://asterix-gerrit.ics.uci.edu/633
Reviewed-by: Yingyi Bu <[email protected]>
Tested-by: Jenkins <[email protected]>


> Limit clause doesn't apply when query against Variables
> -------------------------------------------------------
>
>                 Key: ASTERIXDB-1204
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1204
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Wail Alkowaileet
>            Assignee: Taewoo Kim
>            Priority: Minor
>
> There's a bug in the limit clause when query results assigned to variables:
> - Input:
> {noformat}
> {
>       "id":0,
>       "names":{
>               "count": "1",
>               "name" :{
>                       "firstName" : "wail",
>                       "lastName" : "Alkowaileet"
>               }
>       }
> }
> {
>       "id":1,
>       "names":{
>               "count": "2",
>               "name" :[
>               {
>                       "firstName" : "wail",
>                       "lastName" : "Alkowaileet"
>               },
>               {
>                       "firstName" : "Sattam",
>                       "lastName" : "Alsubaiee"
>               }
>               ]
>       }
> }
> {noformat}
> - DDL:
> {noformat}
> create dataverse ifVerse
> use dataverse ifVerse
> create type ifType as open
> {
>     id: int32
> }
> create dataset ifds(ifType)
> primary key id
> {noformat}
> - DML:
> {noformat}
> use dataverse ifVerse
> insert into dataset ifds(
> {
>       "id":0,
>       "names":{
>               "count": "1",
>               "name" :{
>                       "firstName" : "wail",
>                       "lastName" : "Alkowaileet"
>               }
>       }
> }
> )
> insert into dataset ifds(
> {
>       "id":1,
>       "names":{
>               "count": "2",
>               "name" :[
>               {
>                       "firstName" : "wail",
>                       "lastName" : "Alkowaileet"
>               },
>               {
>                       "firstName" : "Sattam",
>                       "lastName" : "Alsubaiee"
>               }
>               ]
>       }
> }
> )
> {noformat}
> - FLWOR:
> {noformat}
> use dataverse ifVerse
> let $noCoAuth := (for $x in dataset ifds
> where $x.names.count = "1"
> distinct by $x.names.name
> return 
> {
> "firstName" : $x.names.name.firstName,
> "lastName" : $x.names.name.lastName
> }
> )
> let $coAuthList := (for $x in dataset ifds
> let $nameString := "names"
> where $x.names.count != "1"
> return 
> {$nameString:$x.names.name}
> )
> let $coAuth := (for $x in $coAuthList
> for $y in $x.names
> return {
> "firstName" : $y.firstName,
> "lastName" : $y.lastName
> }
> )
> for $x in $coAuth
> limit 1
> return $x
> {noformat}
> - Output (Expecting only one record):
> {noformat}
> { "firstName": "wail", "lastName": "Alkowaileet" }
> { "firstName": "Sattam", "lastName": "Alsubaiee" }
> {noformat}
> - Workaround this bug:
> Assign the query to a variable and return it:
> {noformat}
> use dataverse ifVerse
> let $noCoAuth := (for $x in dataset ifds
> where $x.names.count = "1"
> distinct by $x.names.name
> return 
> {
> "firstName" : $x.names.name.firstName,
> "lastName" : $x.names.name.lastName
> }
> )
> let $coAuthList := (for $x in dataset ifds
> let $nameString := "names"
> where $x.names.count != "1"
> return 
> {$nameString:$x.names.name}
> )
> let $coAuth := (for $x in $coAuthList
> for $y in $x.names
> return {
> "firstName" : $y.firstName,
> "lastName" : $y.lastName
> }
> )
> //Assign the query to a variable and return it:
> let $workAround := (for $x in $coAuth
> limit 1
> return $x)
> return $workAround
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to