X

Oracle Spatial and Graph – technical tips, best practices, and news from the product team

Property Graph Query Language (PGQL) support has been added to Oracle Database 12.2.0.1!

Alan Wu
Architect

Great news! Oracle just released a patch that adds Property Graph Query Language (PGQL) support to the existing property graph functions in Oracle Spatial and Graph in Oracle Database 12c Release 2 (12.2.0.1.).

At a high level, PGQL is a SQL-like declarative language that allows a user to express a graph query pattern that consists of vertices and edges, and constraints on the properties of the vertices and edges.

Once this patch is applied to your database instance, you can run the following quick test, Groovy/Java based, to see how it works.

cd $ORACLE_HOME/md/property_graph/dal/groovy
$ sh ./gremlin-opg-rdbms.sh

--------------------------------


opg-oracledb> // It is very likely that you need to customize
JdbcURL, Username, and Password in the following graph config
setting.

opg-oracledb> //
opg-oracledb> cfg =
GraphConfigBuilder.forPropertyGraphRdbms().setJdbcUrl("jdbc:oracle:thin:@127.0.0.1:1521:orcl")
.setUsername("scott").setPassword("tiger") 
.setName("connections") .setMaxNumConnections(8)
.setLoadEdgeLabel(false) .addVertexProperty("name",
PropertyType.STRING, "default_name")  .addEdgeProperty("cost",
PropertyType.DOUBLE, "1000000")  .build();



opg-oracledb> opg = OraclePropertyGraph.getInstance(cfg);

opg-oracledb> opg.clearRepository();     // start from
scratch


opg-oracledb>
opgdl=OraclePropertyGraphDataLoader.getInstance();


opg-oracledb> vfile="../../data/connections.opv"  //
vertex flat file

==>../../data/connections.opv
opg-oracledb> efile="../../data/connections.ope"  //
edge flat file

==>../../data/connections.ope
opg-oracledb> opgdl.loadData(opg, vfile, efile, 2,
10000, true, null);

==>null

opg-oracledb> opg.countVertices()
==>78
opg-oracledb> opg.countEdges()
==>164


opg-oracledb> // Create an in memory analytics session and
analyst


opg-oracledb> session=Pgx.createSession("session_ID_1");


opg-oracledb> analyst=session.createAnalyst();
opg-oracledb>
opg-oracledb> // Read graph data from database into
memory


opg-oracledb> pgxGraph =
session.readGraphWithProperties(opg.getConfig());

==>PgxGraph[name=connections,N=78,E=164,created=1488415009543]

opg-oracledb> pgxResultSet = pgxGraph.queryPgql("SELECT
n,m WHERE (n) -> (m)")

==>PgqlResultSetImpl[graph=connections,numResults=164]


opg-oracledb> pgxResultSet.print(10);
+------------------------------------+
| n                | m               |
+------------------------------------+
| PgxVertex[ID=2]  | PgxVertex[ID=1] |
| PgxVertex[ID=3]  | PgxVertex[ID=1] |
| PgxVertex[ID=6]  | PgxVertex[ID=1] |
| PgxVertex[ID=7]  | PgxVertex[ID=1] |
| PgxVertex[ID=8]  | PgxVertex[ID=1] |
| PgxVertex[ID=9]  | PgxVertex[ID=1] |
| PgxVertex[ID=10] | PgxVertex[ID=1] |
| PgxVertex[ID=11] | PgxVertex[ID=1] |
| PgxVertex[ID=12] | PgxVertex[ID=1] |
| PgxVertex[ID=19] | PgxVertex[ID=1] |
+------------------------------------+



Cheers,

[1] https://support.oracle.com/epmos/faces/PatchDetail?patchId=25640325

 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services