typeql icon indicating copy to clipboard operation
typeql copied to clipboard

Select all attributes (*) of a Thing

Open richard-julien opened this issue 5 years ago • 3 comments

Problem to Solve

When using Graql every attributes needed in the result must be expressed in the query. For grakn as a SQL like database it can be a bit annoying to express the 25 attributes required.

Current Workaround

No workaround, we need to express all the fields you need

Proposed Solution

Add in the language the SQL select * way of fetching data.

Proposal

Have more convention for variable naming if not specified. like. match $user isa User; has name $n; has email; get;

{ id: "V10003", n: "Julien", email: "[email protected]"}

And so by convention for every attributes match $user isa User; has *; get;

{ id: "V10003", name: "Julien", email: "[email protected]"}

richard-julien avatar Feb 13 '20 19:02 richard-julien

@richard-julien , as a workaround for now (though this may be expensive in terms of queries), you can do:

match $x isa User; $x has attribute $a; get; And then collect all the different attributes that come in in different answers for the same user together :)

flyingsilverfin avatar Feb 27 '20 11:02 flyingsilverfin

What @flyingsilverfin suggested above is the official alternative/workaround, actually. I get that it's not entirely identical, as the attributes need to be collected from all entries in the map, as opposed to one entry containing all attributes.

Did this workaround, work for you, @richard-julien ?

haikalpribadi avatar Jul 02 '20 15:07 haikalpribadi

Hi @haikalpribadi , for now we use a different approach. Will try this approach asap to see if it speedup the queries :)

richard-julien avatar Jul 03 '20 19:07 richard-julien

Closing for now since the has attribute $a is still the recommended approach. This can be used with a group $x to make sure the user doesn't have to collect the values themselves if they arrive out of order.

flyingsilverfin avatar Jan 10 '23 12:01 flyingsilverfin