Optional parameters or default values for parameter for query signature

Hi,

I’d like to be able to have optional parameters eg

CREATE OR REPLACE QUERY(Set|null a=null)

however I can’t see that this is possible. Is there any work around other than creating multiple similar functions?

I’ve noticed it’s possible to have default values for integer parameters eg

CREATE OR REPLACE QUERY(INT a=1)

But I can’t seem to be able to get this to work for null values and more complex types like Set<*>

Cheers,

Rene

Yes, this is possible.

Please see: http://docs.tigergraph.com/dev/gsql-ref/querying/operators-functions-and-expressions#is-null-is-not-null

You’ll see that a literal underscore is used for GSQL querying where you want to specify that the parameter is taking an empty (NULL) value.

With no default specified, the parameter will be empty unless the argument is specified at call time.

For collection types, this is detected with a size() of zero e.g.:

CREATE QUERY nullTest(SET <String> sparm) FOR GRAPH SuppChain {
   IF sparm.size()==0 THEN
      PRINT "sp is empty";
   ELSE
      PRINT sparm;
   END;
}

With simple types, you can use IS NULL.

Hi Jon,

Could you please let me know how can I make the entity_type input parameter an optional parameter?

CREATE QUERY get_inputs_details(vertex node, INT limit_size, INT offset_limit, SETentity_type) FOR GRAPH litecoin { }

Thanks