sql-gremlin icon indicating copy to clipboard operation
sql-gremlin copied to clipboard

Improve finding entity and field nodes

Open kungwangtotvs opened this issue 8 years ago • 3 comments

Here are changes that works for my gremlin implementation again our own database. Please help me review it. Thank you.

kungwangtotvs avatar Mar 13 '17 18:03 kungwangtotvs

Thanks for the PR Kung. I'll take a look.

twilmes avatar Mar 15 '17 01:03 twilmes

Would it be possible for you to provide the schema you're working with along with some queries?

twilmes avatar Mar 15 '17 13:03 twilmes

There are there tables involve in this query: mdmcustomer, mdmticket and mdmopportunity.

the relationship is defined as: mdmcustomer.mdmcompanycode <= mdmticket.mdmcompanycode mdmcustomer.mdmcompanycode <= mdmopportunity.mdmcompanycode

here is the SQL query: select c.mdmcompanycode, count(i.mdmcompanycode), count(o.mdmcompanycode) from mdmcustomer as c join mdmticket as i on c.mdmcompanycode = i.mdmcompanycode join mdmopportunity as o on o.mdmcompanycode = c.mdmcompanycode group by c.mdmcompanycode

Although I did see where I can see the gremlin generated, but I would imaging it should be something like this:

g.V().hasLabel("mdmcustomer").as("customers") .match( __.as("c").both("has Opportunity").count().as("opportunities"), __.as("c").both("has_ticket").count().as("tickets")) .select("customers", "opportunities", "tickets")

But after SQL had been parsed, and creating traversal tree, it traverses from mdmticket to mdmopportunity.

kungwangtotvs avatar Mar 15 '17 18:03 kungwangtotvs