semantalytics / xsparql

14 stars 4 forks source link

grammar doc doesn't show SQL querying #11

Open VladimirAlexiev opened 7 years ago

VladimirAlexiev commented 7 years ago

The doc grammars at https://github.com/semantalytics/xsparql/blob/master/doc/ do not show that XSPARQL can query RDBMS using SQL, something extremely useful and which is used to implement RDB2RDF DM and R2RML. It starts with sqlForClause in the Antlr grammar XSPARQL.g.

Note: grammar.html is the source doc, and the others are derived from it:

Are there any other omissions in the doc grammars?

VladimirAlexiev commented 7 years ago

The SQL syntax is shown in the paper On the semantics of heterogeneous querying of relational, XML, and RDF data with XSPARQL (October 2011), Fig6 "Extension of the XSPARQL syntax (partial)":

XSPARQLExpr ::= (FLWORExpr | SPARQLForClause | SQLForClause)
                            (ReturnClause | ConstructClause)
SQLForClause ::= "for" SelectSpec RelationList SQLWhereClause?
SelectSpec ::= AttrSpecList | "*" | "row" VarRef
AttrSpecList ::= AttrSpec AttrNameSpec? ("," AttrSpec AttrNameSpec?)*
AttrSpec ::= attrName | VarRef | relationName.attrName |
VarRef.attrName | relationName.VarRef | VarRef.VarRef
AttrNameSpec ::= "as" VarRef
RelationList ::= "from" TableSelector ("," TableSelector)*
TableSelector ::= TableName ("as" TableAlias)? | VarRef ("as" TableAlias)?
SQLWhereClause ::= "where" WhereSpecList
WhereSpecList ::= "(" WhereSpecList BooleanOp WhereSpecList ")" |
                              AttrSpec ComparisonOp AttrSpec | AttrSpec ComparisonOp Constant
BooleanOp ::= "and" | "or"
ComparisonOp ::= "=" | "!=" | "!=" | "<" | "<=" | ">" | "=>"

Can someone confirm whether this is accurate, and maybe complete it?

VladimirAlexiev commented 7 years ago

I think this: https://github.com/AKSW/xsparql/commit/35336c142dc44e32c200fd397029926f1d15ac9f#diff-f0c7ce010c23322d880114070859e659R247 fixes the bug that a fake let is required before construct in function definitions. @chile12 How to reflect this fix in the grammar doc?