You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Taewoo Kim (JIRA)" <ji...@apache.org> on 2016/02/14 19:36:18 UTC

[jira] [Resolved] (ASTERIXDB-1204) Limit clause doesn't apply when query against Variables

     [ https://issues.apache.org/jira/browse/ASTERIXDB-1204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Taewoo Kim resolved ASTERIXDB-1204.
-----------------------------------
    Resolution: Fixed

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