How to select only specific fields from vertex type?

I am using below query to select all vertices from a given vertex type.

CREATE DISTRIBUTED QUERY selectAllFromVertex(STRING v_type) FOR GRAPH graph_name {
  vertex_type = {v_type};
  res = SELECT v FROM vertex_type:v;
  PRINT res;

This selects all the fields from Vertex Type. How do I select specific fields?

What do you want to do with the specific field? If you want to print it, all you need to do is specify the field in your PRINT Statement (API v2): PRINT res[,, etc];

See Print documentation at: Output Statements and FILE Objects :: GSQL Language Reference


Also note there is no penalty for selecting all fields, since this is not like relational. Its creating a list of vertexes in memory, so there is no need to subset the fields, until PRINT.

1 Like