AKhatun_WMF added a comment.
Idea on how to store the SPARQL query as a list:
Let's make a list of `generic custom class` **QueryElem[T]**. QueryElem
contains `elemType: String` and `elem: T`.
Classes for each element type needs to be created, e.g `NodeClass extends
QueryElem`. Class defnitions of all elements are given below:
For nodes:
`elemType = "Node", elem: NodeInfo = some_node` (NodeInfo is a case class
containing NodeType and NodeValue like `("NODE_VAR", "x")` )
For expression:
`elemType = "expression"`
Expressions can get quite convoluted, 1 variable, 2 variable, n variable.
Like BIND("AK" as ?x), (?x+?y as ?z), (REGEX("[abc]*") as ?x) respecively.
Moreover they can go very deep as well like FILTER(?x==1 || ?y==2 || ?z==3)
**I am not entirely sure how to represent expressions**
For BGP:
`elemType = "BGP", elem: List[TripleInfo] = List(triple1, triple2, triple3,
triple4, ...)` (TripleInfo contains NodeInfo for Sub, Pred and Obj)
For services:
`elemType = "service", serviceName:"service_name", elem: BGP` (service_name
like wikibase:label)
For tables:
`elemType = "table", elem: TableData`
TableData is: `tableVars: List[NodeInfo], tableRow: List[Rows]`
Row is: `List[NodeInfo]`
For paths (sub path obj) :
A path predicate is identified as `PATH` in NodeType anyways, so we can
consider paths to be ordinary triples. Or create a special `pathTriple`
`elemType = "pathTriple", elem: TripleInfo`
For filters:
`elemType = "filter", elem: Expression` (Expression class as described above)
For extends:
`elemType = "extend", elem: Expression, expVar: NodeInfo` (Expression class
as described above)
e.g `(?x+?y as ?z)`, here `?z` is the expVar and elem is `?x+?y`
elem can be a single Node as well: `BIND ("AK" as ?x)`
Could it be anything else? **This requires more thinking and not sure what to
put in `elem` for extends.**
Op Names:
`elemType = "operations", elem = "join"` (elem can be join, optional, project
etc. Sometimes elem will be redundant, like BGP, path, table etc which have
their own classes)
Let me know if and what I am missing, how else can we represent a query as
list?
TASK DETAIL
https://phabricator.wikimedia.org/T283256
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: AKhatun_WMF
Cc: Gehel, dcausse, CBogen, Aklapper, AKhatun_WMF, JAllemandou, Invadibot,
MPhamWMF, maantietaja, Akuckartz, Nandana, Namenlos314, Lahi, Gq86,
Lucas_Werkmeister_WMDE, GoranSMilovanovic, QZanden, EBjune, merbst,
LawExplorer, _jensen, rosalieper, Scott_WUaS, Jonas, Xmlizer, jkroll,
Wikidata-bugs, Jdouglas, aude, Tobias1984, Manybubbles, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]