Download and Install SAP HANA Graph Viewer and Query Graph Workspace
To install SAP HANA Graph Viewer to work on relational vertex and edge data on a graph visually, SAP HANA database developers can download and install SAP HANA Graph Viewer. Besides visualizing vertices and edges of a graph workspace, HANA Graph Viewer enables developers to create SQL queries easily protecting them from the complexity of Graph language or GraphScript.
In SAP note 2306732, GraphViewer is described as a visualization tool for SAP users to interact with created graph workspaces in a SAP HANA system.
Download SAP HANA Graph Viewer Visualization Tool
Let's start to download SAP HANA Graph Viewer and complete Graph Viewer installation step by step.
SAP users can free download SAP HANA Graph Viewer from SAP Software Downloads portal (service marketplace).
In Downloads search for "SAP HANA GRAPH VIEWER"
Downloadable setup file for SAP HANA Graph Viewer visualization tool is HCOGRAPHVIEWER12_4-70001725.ZIP
As seen in following screenshot the total size is just 92.3 KB
Install SAP HANA Graph Viewer Delivery Unit
When SAP users unzip the compressed download file, they will see HCOGRAPHVIEWER.tgz archive file.
Actually this is a Delivery Unit for the Graph Viewer that we will import to our SAP HANA database system soon.
To import the delivery unit into target HANA database, on SAP HANA Studio Systems window, connect to the target HANA system.
Then follow menu options: File > Import...
When the Import wizard is displayed on the screen, drill-down to SAP HANA Content > Delivery Unit
Press Next button.
Select the target HANA system for import delivery unit operation, actually the SAP HANA system where you want to install SAP HANA Graph Viewer tool.
Click Next to continue.
To import the delivery unit provided for SAP HANA Graph Viewer we have just downloaded from SAP Software Downloads portal, choose option "Client" and point the .tgz file "HCOGRAPHVIEWER.tgz" in File selection by browsing with Windows Explorer.
An import simulation process will execute and display simulation results as seen in below screenshot.
If it is all Green then click Finish to complete the import task of SAP HANA Graph Viewer tool delivery unit into selected HANA system.
The result of the import delivery unit of Graph Viewer can be displayed on Job Log window within SAP HANA Studio IDE.
Create User on HANA Database for GraphViewer
Let's now create a HANA database user to work with virtualization tool GraphViewer which will help us avoid GraphScript language. And then grant SELECT on schema where the graph database table will be created. It is possible to use your own user for logon to SAP HANA Graph Viewer application, if so you will not require a database user. Neither you have to grant SELECT permissions on the target schema, too.
Launch SAP HANA Graph Viewer Visualization Tool
Launch a web browser and then navigate to URL "http://[saphanaserver:80][instancenumber]/sap/hana/graph/viewer/" for SAP HANA Graph Viewer.
If you don't know the SAP HANA server address of your target system, you can find it on the Administration console that can be launched within SAP HANA Studio via context menu on the target HANA system: "Configuration and Monitoring > Open Administration"
80 is the default port. Following two digit number is the instance number. You will find this information again on the Administration console.
I know you have been dissapointed with the first screen of SAP HANA Graph Viewer.
That is because we have not yet defined any Graph WorkSpace in our HANA database.
Then SAP developers can see the power of Graph Viewer as a virtualization tool and as a graphical tool to convert Graph Language commands into SQLScript code.
That is a very important feature of Graph Viewer. Important because, Graph language is has similiarities with SQL and SQLScript but has important limitations and differences that can hurt database developers as a programmer :)
But Graph Viewer provides parametric SQL Views (created from HANA database procedures by using the With Result View extension) to query Graph data using SQLScript instead of coding pure Graph Language.
Create HANA Database Graph Workspace using SQLScript
For demo purposes, SAP HANA Academy provides sample Graph scripts that you can find at github.com. But I will try to create a very simple Graph workspace for SAP users.
Let's create two tables; one for Vertex data and the other table is for Edge data.
Here is the SQLScript DDL codes for table creation.
I want to share a few important notes with SAP developers at this point.
Both tables, vertex and edge tables must have primary key for enabling unique values for key columns in below Create Graph Workspace command
And tinyint column type, for example, is not supported as a valid KEY COLUMN data type. But you can use Int, BigInt, Varchar and NVarChar data types for Key Columns.
Additionally, the source column and the target column of the edge table must have NOT NULL constraint.
Let's now populate some sample data into HANA Graph tables (vertex and edge tables)
Let's not create our first Graph Workspace on our SAP HANA system using SQLScript command "Create Graph Workspace" command as follows:
Work with SAP HANA Graph Viewer
Now we have our sample data in our Vertex and Edge tables and created our first Graph Workspace on our HANA database.
Let's launch HANA Graph Viewer tool again and select recently created graph workspace on the dropdown on initial screen.
Database developers can easily understand and learn the Graph Viewer toolbar.
But it is important to understand the Graph Interaction tool within the GraphViewer.
This section enables Graph database developers to create SQLScript codes replacing the necessity for creating HANA procedures created with Graph language
For example, in Neighborhood Search tab, database developer can query Graph Workspace data so that the list of cities that are directly connected to Izmir can be queried as follows.
The resultant cities are seen with black color on the Graph. You see it is very simple querying and searching for vertex (or nodes) that you are searching for.
And if you click on the downward arrow button (like a download button), it displays the SQLScript query to get the same result for database developer.
You see following is the SQL query generated by the Graph Viewer
Shortest Path
Following is the shortest path query from Istanbul to Antalya
And the result in the visualization tool
Tutorials and Reference Documents for Graph on SAP HANA
Please check gitHub for SQLScript samples provided by SAP HANA Academy and please have a look at the online video Graph tutorials publihed at youtube.
Another resource which can be used for SAP professionals who want to work with Graph data is Graph Processing with SAP HANA 2
GraphScript, Graph Language reference is reachable at SAP HANA Graph Reference and SAP HANA database developers can find a downloadable PDF document here.