You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Wail Alkowaileet (JIRA)" <ji...@apache.org> on 2015/11/30 11:51:10 UTC
[jira] [Created] (ASTERIXDB-1204) Limit clause doesn't apply when
query against Variables
Wail Alkowaileet created ASTERIXDB-1204:
-------------------------------------------
Summary: 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
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:
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)