Tigergraph - recreate tuples

129 Views Asked by At

I need to write a command-line utility which redefines/updates the graph schema.

For doing this I need to:

  • drop the graph
  • drop existing tuples
  • define new tuples
  • define a new graph

The problem is in the "drop existing tuples" stage. I do it by running the following command for all tuple names which I have to recreate:

gsql 'DROP TUPLE < tupleName >'

This works well for Tigergraph v3.1.2 because DROP TUPLE MyTuple drops MyTuple if it exists or ignores the statement otherwise.

But for Tigergraph v3.5.1 this strategy doesn't work because it fails if MyTuple doesn't exist.

So now I need to run DROP TUPLE only for those tuples which were created before.

But the problem is that there is no way to list all tuples (e.g. there is no Show tuples command). And I cannot use DROP ALL because I need to update only the specific graph and don't touch everything else.

1

There are 1 best solutions below

0
On

You can use session parameter exit_on_error, like:

gsql "set exit_on_error = \"false\"\n
drop tuple mytuple\n
create tuple ...
create graph ...
"

You can also use it in a .gsql file.

doc: https://docs.tigergraph.com/tigergraph-server/current/gsql-shell/gsql-sessions#_session_parameters