How to create a list datatype in nebula?

Hi All,

I am trying to create tag with list data type. But it does not work.

Does Nebula support list datatypes…I don’t see any examples on how to create a tag with list data types.
SQL:-

CREATE TAG IF NOT EXISTS users(id string,name string, place string, hobbies [string])" 

Error:-

ErrorCode: -1004, ErrorMsg: SyntaxError: syntax error near `[string]'

Thanks.

1 Like

Dear @akhilravuri1 ,

I am sorry that currently, nebula doesn’t support data persistent in list/set, the list/set can only be assembled on the fly in a query. :sob:

Hi @wey

I was trying to fetch the edges between to vertices. And I have use fetch Query but it returns only rank 0 edge. But want it to return all the rank edges.

FETCH PROP ON edgeName “sourceId” → “destinationId”;

Thanks,
Akhil

If the previous src_id and dst_id is known, we could use GO instead to get all edges(with all ranks), fetch now needs to explicit provide rank.

If this is the start of the query, we will need to create index on edge to enable this with lookup.

CREATE EDGE INDEX e1_index on e1()
rebuild edge index e1_index
(root@nebula) [basketballplayer]> lookup on e1 yield edge as e
+------------------------+
| e                      |
+------------------------+
| [:e1 "10"->"11" @0 {}] |
| [:e1 "10"->"11" @1 {}] |
| [:e1 "10"->"11" @2 {}] |
+------------------------+
CREATE EDGE IF NOT EXISTS e1();
INSERT EDGE e1 () VALUES "10"->"11":();
INSERT EDGE e1 () VALUES "10"->"11"@1:();
INSERT EDGE e1 () VALUES "10"->"11"@2:();

Hi @wey

Thanks for the quick reply.
lookup on e1 yield edge as e will reterive the all the edges between all the scr’s and dot’s. But how can we limit it for the given scr and dest. Like…

lookup on e1 where e1.Scr = "src" and e1.Dst="dst" yield edge as prop(e)

We have used Go to get the data but it retrieves the data in 1133272/1136350 us.
And Fetch is taking 5631/7194 us.
we have used FIND ALL PATH WITH PROP FROM also which takes 909324/912559 us
Match is taking too much of time and if data is more it doesn’t even return the result.

To retrieve the data faster we found FETCH is the best case.

The workaround we have is to use the below

FETCH PROP ON edge "scr" ->"Dest"@0, "scr" ->"Dest"@1, "scr" ->"Dest"@2, "scr" ->"Dest"@3;

But we are not sure about how many edges will be there so we cannot go with this.
So can you please help us if there is a way to do this using FETCH or any way to retrieve the data faster.

Thanks,
Akhil

Sorry @akhilravuri1 , After revisiting this, I think maybe for now match (m:t1)-[e:e1]->(n:t1) WHERE id(m)=="10" AND id(n)=="11" return e is the best, as the getEdges/fetch edge not yet support wildcard range.

The differences between MATCH and FETCH here are MATCH now starts from the vid and FETCH is doing this by getEdge().

for this reason, I see to explicitly providing tags of m, and n could be slightly faster.

(root@nebula) [basketballplayer]> match (m:t1)-[e:e1]->(n:t1) WHERE id(m)=="10" AND id(n)=="11" return e
+------------------------+
| e                      |
+------------------------+
| [:e1 "10"->"11" @0 {}] |
| [:e1 "10"->"11" @1 {}] |
| [:e1 "10"->"11" @2 {}] |
+------------------------+
Got 3 rows (time spent 4438/8841 us)

Wed, 13 Apr 2022 10:05:48 CST

(root@nebula) [basketballplayer]> match (m)-[e:e1]->(n) WHERE id(m)=="10" AND id(n)=="11" return e
+------------------------+
| e                      |
+------------------------+
| [:e1 "10"->"11" @0 {}] |
| [:e1 "10"->"11" @1 {}] |
| [:e1 "10"->"11" @2 {}] |
+------------------------+
Got 3 rows (time spent 4814/9435 us)

Wed, 13 Apr 2022 10:05:56 CST

I will create an issue on requesting getEdges() and fetch edge to support get wildcard rank.

Thanks!

Also, match in my env could be faster as Prune properties/no need to collect columns of dedup by jievince · Pull Request #3953 · vesoft-inc/nebula · GitHub is introduced. It will be in 3.1(already in master)

(root@nebula) [basketballplayer]> explain match (m:t1)-[e:e1]->(n:t1) WHERE id(m)=="10" AND id(n)=="11" return e
Execution succeeded (time spent 1260/12944 us)

Execution Plan (optimize time 495 us)

-----+----------------+--------------+----------------+-----------------------------------------------------
| id | name           | dependencies | profiling data | operator info                                      |
-----+----------------+--------------+----------------+-----------------------------------------------------
| 13 | Project        | 10           |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "e"                                          |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__Project_8"                          |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar: __Filter_10                              |
|    |                |              |                | columns: [                                         |
|    |                |              |                |   "$-.e[0]"                                        |
|    |                |              |                | ]                                                  |
-----+----------------+--------------+----------------+-----------------------------------------------------
| 10 | Filter         | 5            |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "m",                                         |
|    |                |              |                |       "e",                                         |
|    |                |              |                |       "n"                                          |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__Filter_10"                          |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar: __AppendVertices_5                       |
|    |                |              |                | condition: ((id($-.m)=="10") AND (id($-.n)=="11")) |
|    |                |              |                | isStable: false                                    |
-----+----------------+--------------+----------------+-----------------------------------------------------
|  5 | AppendVertices | 4            |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "m",                                         |
|    |                |              |                |       "e",                                         |
|    |                |              |                |       "n"                                          |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__AppendVertices_5"                   |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar: __Traverse_4                             |
|    |                |              |                | space: 16                                          |
|    |                |              |                | dedup: true                                        |
|    |                |              |                | limit: 0                                           |
|    |                |              |                | filter:                                            |
|    |                |              |                | orderBy: []                                        |
|    |                |              |                | src: none_direct_dst($-.e)                         |
|    |                |              |                | props: [                                           |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 18                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "age",                                       |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 23                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 28                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "age",                                       |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 17                                    |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | exprs:                                             |
|    |                |              |                | vertex_filter: t1._tag IS NOT EMPTY                |
|    |                |              |                | if_track_previous_path: true                       |
-----+----------------+--------------+----------------+-----------------------------------------------------
|  4 | Traverse       | 2            |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "m",                                         |
|    |                |              |                |       "e"                                          |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__Traverse_4"                         |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar: __Dedup_2                                |
|    |                |              |                | space: 16                                          |
|    |                |              |                | dedup: true                                        |
|    |                |              |                | limit: -1                                          |
|    |                |              |                | filter:                                            |
|    |                |              |                | orderBy: []                                        |
|    |                |              |                | src: $-._vid                                       |
|    |                |              |                | edgeTypes: []                                      |
|    |                |              |                | edgeDirection: OUT_EDGE                            |
|    |                |              |                | vertexProps: [                                     |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 18                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "age",                                       |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 23                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 28                                    |
|    |                |              |                |   },                                               |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "name",                                      |
|    |                |              |                |       "age",                                       |
|    |                |              |                |       "_tag"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "tagId": 17                                    |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | edgeProps: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "props": [                                     |
|    |                |              |                |       "_src",                                      |
|    |                |              |                |       "_type",                                     |
|    |                |              |                |       "_rank",                                     |
|    |                |              |                |       "_dst"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "26"                                   |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | statProps:                                         |
|    |                |              |                | exprs:                                             |
|    |                |              |                | random: false                                      |
|    |                |              |                | vertex filter: t1._tag IS NOT EMPTY                |
|    |                |              |                | if_track_previous_path: false                      |
-----+----------------+--------------+----------------+-----------------------------------------------------
|  2 | Dedup          | 1            |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "_vid"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__Dedup_2"                            |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar: __VAR_0                                  |
-----+----------------+--------------+----------------+-----------------------------------------------------
|  1 | PassThrough    | 3            |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [                                  |
|    |                |              |                |       "_vid"                                       |
|    |                |              |                |     ],                                             |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__VAR_0"                              |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
|    |                |              |                | inputVar:                                          |
-----+----------------+--------------+----------------+-----------------------------------------------------
|  3 | Start          |              |                | outputVar: [                                       |
|    |                |              |                |   {                                                |
|    |                |              |                |     "colNames": [],                                |
|    |                |              |                |     "type": "DATASET",                             |
|    |                |              |                |     "name": "__Start_3"                            |
|    |                |              |                |   }                                                |
|    |                |              |                | ]                                                  |
-----+----------------+--------------+----------------+-----------------------------------------------------

Wed, 13 Apr 2022 10:11:16 CST

(root@nebula) [basketballplayer]> explain FETCH PROP ON e1 "10" -> "11" YIELD edge AS e
Execution succeeded (time spent 591/5097 us)

Execution Plan (optimize time 95 us)

-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------
| id | name     | dependencies | profiling data | operator info                                                                          |
-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------
|  3 | Project  | 2            |                | outputVar: [                                                                           |
|    |          |              |                |   {                                                                                    |
|    |          |              |                |     "colNames": [                                                                      |
|    |          |              |                |       "e"                                                                              |
|    |          |              |                |     ],                                                                                 |
|    |          |              |                |     "type": "DATASET",                                                                 |
|    |          |              |                |     "name": "__Project_3"                                                              |
|    |          |              |                |   }                                                                                    |
|    |          |              |                | ]                                                                                      |
|    |          |              |                | inputVar: __Filter_2                                                                   |
|    |          |              |                | columns: [                                                                             |
|    |          |              |                |   "EDGE AS e"                                                                          |
|    |          |              |                | ]                                                                                      |
-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------
|  2 | Filter   | 1            |                | outputVar: [                                                                           |
|    |          |              |                |   {                                                                                    |
|    |          |              |                |     "colNames": [],                                                                    |
|    |          |              |                |     "type": "DATASET",                                                                 |
|    |          |              |                |     "name": "__Filter_2"                                                               |
|    |          |              |                |   }                                                                                    |
|    |          |              |                | ]                                                                                      |
|    |          |              |                | inputVar: __GetEdges_1                                                                 |
|    |          |              |                | condition: ((__EMPTY__!=e1._src) AND ((__EMPTY__!=e1._dst) AND (__EMPTY__!=e1._rank))) |
|    |          |              |                | isStable: false                                                                        |
-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------
|  1 | GetEdges | 0            |                | outputVar: [                                                                           |
|    |          |              |                |   {                                                                                    |
|    |          |              |                |     "colNames": [],                                                                    |
|    |          |              |                |     "type": "DATASET",                                                                 |
|    |          |              |                |     "name": "__GetEdges_1"                                                             |
|    |          |              |                |   }                                                                                    |
|    |          |              |                | ]                                                                                      |
|    |          |              |                | inputVar: __VAR_0                                                                      |
|    |          |              |                | space: 16                                                                              |
|    |          |              |                | dedup: false                                                                           |
|    |          |              |                | limit: 9223372036854775807                                                             |
|    |          |              |                | filter:                                                                                |
|    |          |              |                | orderBy: []                                                                            |
|    |          |              |                | src: COLUMN[0]                                                                         |
|    |          |              |                | type: 26                                                                               |
|    |          |              |                | ranking: COLUMN[1]                                                                     |
|    |          |              |                | dst: COLUMN[2]                                                                         |
|    |          |              |                | props: [                                                                               |
|    |          |              |                |   {                                                                                    |
|    |          |              |                |     "props": [                                                                         |
|    |          |              |                |       "_dst",                                                                          |
|    |          |              |                |       "_rank",                                                                         |
|    |          |              |                |       "_src",                                                                          |
|    |          |              |                |       "_type"                                                                          |
|    |          |              |                |     ],                                                                                 |
|    |          |              |                |     "type": "26"                                                                       |
|    |          |              |                |   }                                                                                    |
|    |          |              |                | ]                                                                                      |
|    |          |              |                | exprs:                                                                                 |
-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------
|  0 | Start    |              |                | outputVar: [                                                                           |
|    |          |              |                |   {                                                                                    |
|    |          |              |                |     "colNames": [],                                                                    |
|    |          |              |                |     "type": "DATASET",                                                                 |
|    |          |              |                |     "name": "__Start_0"                                                                |
|    |          |              |                |   }                                                                                    |
|    |          |              |                | ]                                                                                      |
-----+----------+--------------+----------------+-----------------------------------------------------------------------------------------

Wed, 13 Apr 2022 10:11:22 CST

issue raised: FETCH EDGE for wildcard of rank · Issue #4144 · vesoft-inc/nebula · GitHub

1 Like

@wey.

Thanks for the quick reply.

Right now we have huge data that match is taking 20 sec to return the edges(using your query by explicitly providing tags ) and we are using 2.6 so any changes regarding match in 3.0 to increase performance?

One more question when we run match query match (m:t1)-[e:e1]->(n:t1) RETURN count(e)

It fetches all the data into RAM and fails because our data is very use that we cannot store it in RAM. Is it ideal way to do count?

We have used submit job stats; show stats; to get the count but just wanted to know how why match query loads that data into StorageD RAM and send it to graphd RAM where the count is happening.

Thanks,
Akhil