Florian
February 25, 2021, 2:16pm
1
Report a Dgraph Bug
What version of Dgraph are you using?
Dgraph Version
$ dgraph version
v20.11.0
Have you tried reproducing the issue with the latest release?
What is the hardware spec (RAM, OS)?
Steps to reproduce the issue (command/config used to run Dgraph).
Run an Query with a Value Variable and this constellation!
length as SOMEPREDICATE
and use it in for example first
(first: val(length))
I get this exception!
{
"name": "t",
"url": "http://localhost:8080/query?timeout=20s",
"errors": [
{
"message": ": while converting to subgraph: strconv.ParseInt: parsing \"ct\": invalid syntax",
"extensions": {
"code": "ErrorInvalidRequest"
}
}
]
}
I tried several things, defining predicate as string, integer, used count, max, min
Everytime u get this error!
Expected behaviour and actual result.
It should take the value and use it to limit the elements
Found similar Topic where the last statment is on fixed bug
romshark commented :
I think I faced a similar problem working on my dgraph tech-demo . I’m trying to implement pagination and this is the query I assumed to work:
query PostsPage(
$first: int = 4,
$id: string = "ce9f834c2fd143e7a0994cd01564d990"
) {
var(func: eq(Post.id, $id)) {
p as uid
}
posts(
func: has(Post.id),
orderasc: Post.id,
after: val(p),
first: $first
) {
uid
Post.id
Post.title
Post.contents
}
}
Unfortunately, it seems like I can’t…
chewxy
(chewxy)
February 26, 2021, 3:22am
2
Hi,
I didn’t quite understand the steps to reproduce it. Do you mean something like this:
{
var (func: allofterms(name@en, "Steven Spielberg")) @filter(has(director.film)){
length as count(director.film)
}
me(func: allofterms(name@en, "Steven Spielberg")) @filter(has(director.film)){
director.film(first: val(length)) {
name@en
}
}
}
If this is the case, then you’re right - it doesn’t work.
I’m doubtful of the previous claim that this was in the changelist for 20.07. @hardik can you please check this out?
EDIT: I found the Pull Request:
dgraph-io:release/v20.07
← dgraph-io:neeraj/v20.07-paginationUID
opened 08:24PM - 02 Oct 20 UTC
<!--
Your title must be in the following format: topic(Area): Feature
Topic mu… st be one of build|ci|docs|feat|fix|perf|refactor|chore|test
Sample Titles:
feat(Enterprise): Backups can now get credentials from IAM
fix(Query): Skipping floats that cannot be Marshalled in JSON
perf: [Breaking] json encoding is now 35% faster if SIMD is present
chore: all chores/tests will be excluded from the CHANGELOG
Please add a description with these things:
1. A good description explaining the problem and what you changed.
2. If it fixes any GitHub issues, say "Fixes #GitHubIssue".
3. If it corresponds to a Jira issue, say "Fixes DGRAPH-###".
4. If this is a breaking change, please put "[Breaking]" in the title. In the description, please put a note with exactly who these changes are breaking for.
-->
Pagination param "after" does not work when using func: uid(v)
for query
```
{
var(func: has(name@en), first: 50) {
test as uid
}
ss(func: uid(test), first: 2, after: 0x6) {
uid
}
}
```
the response was
```
{
"data": {
"ss": [
{
"uid": "0x4"
},
{
"uid": "0x6"
}
]
}
}
```
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/dgraph-io/dgraph/6631)
Docs Preview: [<img src="https://bl.ocks.org/prashant-shahi/raw/3a9f99bec84231cfe3c0e82cf883f159/0e588d908ad8c8b10958b87ebdd2ba68779ccf4f/dgraph.svg" height="34" align="absmiddle" alt="Dgraph Preview"/>](https://dgraph-70fd76f0af-98614.surge.sh)
It is specific to uid()
, not val()
So I’m accepting this as a feature request
Florian
February 26, 2021, 5:22am
4
Good morning!
Yes thats exactly what I mean!
I saw the linked post and didn’t know if its already implemented!
But it seems too
Atleast what I understand from error I have got
while converting to subgraph: strconv.ParseInt: parsing \"ct\": invalid syntax
The error didn’t say that it can’t convert val (), it can’t convert the value of variable
Am I right in this theorie?
Greetings
chewxy
(chewxy)
February 26, 2021, 5:59am
5
So the steps in handling a query is something along the lines of this (things in bold are data structures, things not in bold are functions):
Query –parse → GraphQuery –convert to SubGraph → SubGraph –process request → Results
… … … ↑↑↑ … … … …
The error happens in the parse phase (where the arrows point to).
That is, our language spec doesn’t allow for identifiers at that position. The spec needs to be updated to allow that.
1 Like
Florian
February 26, 2021, 6:11am
6
Ah okay.
Is there any estimation when this get’s implemented?
I would need it for a project
Thanks!
chewxy
(chewxy)
February 26, 2021, 6:14am
7
Unfortunately I won’t be able to give you an estimate. @hardik might, since he’s managing the queue and features.
hardik
(Hardikkumar Patel)
March 1, 2021, 9:56am
9
We are analyzing whether this should be part of Dgraph or not. We will keep you posted.
1 Like
minhaj
(Minhaj Shakeel)
March 3, 2021, 10:46am
10
Hey @Florian , Currently variables are not supported in first
and offset
parameters. However, can you elaborate on your use case with some sample queries so that we can look into it?
hardik
(Hardikkumar Patel)
March 19, 2021, 5:50am
11
@Florian would you help Minhaj with his query?? ^^
Hello,
I am sorry for my late answer, the last weeks I was on hurry!
Example:
query {
array(func: uid(0x2723)){
l as Length
Array(first: val(l))
{
name
}
}
}
{
"set":
{
"uid": "_:root",
"Length": 10,
"Array":[
{
"name": "1"
},
{
"name": "2"
},
{
"name": "3"
},
{
"name": "4"
},
{
"name": "5"
},
{
"name": "6"
},
{
"name": "7"
}
]
}
}
Greetings
Florian