Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

judgment of EMPTY #2666

Closed
cooper-lzy opened this issue Jun 21, 2021 · 2 comments
Closed

judgment of EMPTY #2666

cooper-lzy opened this issue Jun 21, 2021 · 2 comments
Assignees
Labels
type/feature req Type: feature request
Milestone

Comments

@cooper-lzy
Copy link
Contributor

Extract empty to judge, there are some exceptions:

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 1
+---+-------------+----+---+
| a | b           | c  | d |
+---+-------------+----+---+
|   | "player101" | 95 |   |
+---+-------------+----+---+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 1 ; yield $var.a is EMPTY, $var.a + 1 IS NOT EMPTY , sum($var.a), sum($var.a+1), count($var.a), max($var.a)
+-----------------+-------------------------+-------------+-----------------+---------------+-------------+
| $var.a IS EMPTY | ($var.a+1) IS NOT EMPTY | sum($var.a) | sum(($var.a+1)) | count($var.a) | max($var.a) |
+-----------------+-------------------------+-------------+-----------------+---------------+-------------+
| true            | false                   | 0           | 0               | 0             | __NULL__    |
+-----------------+-------------------------+-------------+-----------------+---------------+-------------+

(root@nebula) [basketballplayer]> GO FROM "player100" OVER * REVERSELY YIELD serve.end_year AS a , follow.degree as b   | group by $-.b  yield max($-.a) as cc
+----------+
| cc       |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+
| __NULL__ |
+----------+

(root@nebula) [basketballplayer]> GO FROM "player100" OVER * REVERSELY YIELD serve.end_year AS a , follow.degree as b   | group by $-.b  yield count($-.a) as cc
+----+
| cc |
+----+
| 0  |
+----+
| 0  |
+----+
| 0  |
+----+
| 0  |
+----+
| 0  |
+----+
| 0  |
+----+
| 0  |
+----+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 3 ;
+-----------+-------------+----+------+
| a         | b           | c  | d    |
+-----------+-------------+----+------+
|           | "player125" | 95 |      |
+-----------+-------------+----+------+
|           | "player101" | 95 |      |
+-----------+-------------+----+------+
| "team204" |             |    | 1997 |
+-----------+-------------+----+------+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 3 ; fetch prop on team $var.a
+----------------------------------+
| vertices_                        |
+----------------------------------+
| ("team204" :team{name: "Spurs"}) |
+----------------------------------+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 2 ; yield -(size($var.a) )
+-----------------+
| -(size($var.a)) |
+-----------------+
|                 |
+-----------------+
|                 |
+-----------------+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 2 ; yield toBoolean($var.a)
+-------------------+
| toBoolean($var.a) |
+-------------------+
| __NULL__          |
+-------------------+
| __NULL__          |
+-------------------+

(root@nebula) [basketballplayer]> $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d |  order by $-.a | limit 2 ; yield collect($var.a)
+-----------------+
| collect($var.a) |
+-----------------+
| []              |
+-----------------+
@czpmango czpmango self-assigned this Jun 24, 2021
@czpmango
Copy link
Contributor

Thank you for such a detailed test!

As far as I can see, the most results are expected. The Aggregate function is basically executed by ignoring null and empty and passing an exception. And different functions will have different default initial values( such as 0 for count and [] for collect).

Here are some explanations for some of above queries:

  1. $var = GO FROM "player100" OVER * yield serve._dst as a, follow._dst as b, follow.degree as c, serve.start_year as d | order by $-.a | limit 1 ; yield $var.a is EMPTY, $var.a + 1 IS NOT EMPTY , sum($var.a), sum($var.a+1), count($var.a), max($var.a)
    $var.a is empty and empty+1 is null, so they are ignored by the aggregate function and return default values.

  2. GO FROM "player100" OVER * REVERSELY YIELD serve.end_year AS a , follow.degree as b | group by $-.b yield count($-.a) as cc
    count(empty) just return default values.

  3. GO FROM "player100" OVER * REVERSELY YIELD serve.end_year AS a , follow.degree as b | group by $-.b yield max($-.a) as cc
    You could execute the GO FROM "player100" OVER * REVERSELY YIELD serve.end_year AS a , follow.degree as b statement, bcz I don't know about your data.

@CPWstatic
Copy link
Contributor

Please keep track with #2594.

@CPWstatic CPWstatic transferred this issue from vesoft-inc/nebula-graph Aug 28, 2021
@CPWstatic CPWstatic added the type/feature req Type: feature request label Aug 28, 2021
@Sophie-Xie Sophie-Xie assigned nevermore3 and unassigned czpmango Oct 15, 2021
@Sophie-Xie Sophie-Xie added this to the v3.0.0 milestone Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature req Type: feature request
Projects
No open projects
Status: Done
Development

No branches or pull requests

5 participants