Reputation: 21
I'm working in memSQL on a project to identify certain batter
pitcher
relationships in the MLB; where I look at what batters
had the most success against various pitchers
and when
. With the goal of creating a heat map of teams
and lineups of a specific year(s)(collection of batters
) against various groups of pitchers
.
I ran into a problem trying to query for teams with a positive net score against pitchers. When looking for all Batter of a given team.
I came across Grakn and this blog post: https://blog.grakn.ai/comparing-graql-to-sql-part-2-2-745f79e9528d
Seems that I could utilise rules to then query for something like this.
Taking a stab at the rule - I want to make team performance
against a pitcher
based on a collection of batter performance
of that same pitcher
.
I wrote this query, which would just query for at-bat performance
where batter
is in a plays-for
with a given team
. However the query doesn't give me the result I am expecting?
when {
(batting: $b, pitching: $p) isa at-bat;
(playing: $b, plays-for: $t) isa team;
}, then {
(plays-for: $c, pitching: $d) isa at-bat;
};
Also does anyone knows when these rules are computed and what is the performance overhead?
Upvotes: 1
Views: 86
Reputation: 61
Just to check quickly, are you defining the rule in your schema? Rules need to be inserted into Grakn using a define
statement, since they are treated like schema elements. If you are trying to run it in-line in the query I would have thought you would get an error, but maybe that's not what you are doing and I am misunderstanding.
To answer the other question, rules are computed at query time, we detect which rules might change the outcome of a query and effectively make it a part of the query traversal, so in theory it works like a normal transitive search over a graph. In practice it's a bit different.
Upvotes: 1