--- a/src/main/scala/RDB2RDFMain.scala Sun Jan 31 09:32:43 2010 -0500
+++ b/src/main/scala/RDB2RDFMain.scala Sun Jan 31 10:39:08 2010 -0500
@@ -20,50 +20,50 @@
case class PrimaryKey(attr:sql.Attribute)
sealed abstract class Binding
-case class RDFNode(relaliasattr:sql.RelAliasAttribute) extends Binding
-case class Str(relaliasattr:sql.RelAliasAttribute) extends Binding
-case class Int(relaliasattr:sql.RelAliasAttribute) extends Binding
-case class Enum(relaliasattr:sql.RelAliasAttribute) extends Binding
+case class RDFNode(relvarattr:sql.RelVarAttr) extends Binding
+case class Str(relvarattr:sql.RelVarAttr) extends Binding
+case class Int(relvarattr:sql.RelVarAttr) extends Binding
+case class Enum(relvarattr:sql.RelVarAttr) extends Binding
object RDB2RDF {
case class R2RState(joins:util.AddOrderedSet[sql.Join], varmap:Map[sparql.Var, SQL2RDFValueMapper], exprs:Set[sql.Expression])
sealed abstract class FullOrPartialBinding
- case class FullBinding(relaliasattr:sql.RelAliasAttribute) extends FullOrPartialBinding
- case class BindingConstraint(expr:sql.RelationalExpression, relaliasattr:sql.RelAliasAttribute)
+ case class FullBinding(relvarattr:sql.RelVarAttr) extends FullOrPartialBinding
+ case class BindingConstraint(expr:sql.RelationalExpression, relvarattr:sql.RelVarAttr)
case class PartialBinding(binders:Set[BindingConstraint]) extends FullOrPartialBinding
def toExpr(against:FullOrPartialBinding):sql.Expression = {
/* if (g_union1._DISJOINT_ != 0, g_union1.who, if (g_union2._DISJOINT_ != 3, g_union2.who, NULL)) */
against match {
- case FullBinding(relaliasattr) =>
- sql.PrimaryExpressionAttr(relaliasattr)
+ case FullBinding(relvarattr) =>
+ sql.PrimaryExpressionAttr(relvarattr)
case PartialBinding(binders) =>
binders.toList.reverse.foldLeft(sql.ConstNULL():sql.Expression)((exp, binding) => {
- val BindingConstraint(expr, relaliasattr) = binding
- sql.IfElse(expr, sql.PrimaryExpressionAttr(relaliasattr), exp)
+ val BindingConstraint(expr, relvarattr) = binding
+ sql.IfElse(expr, sql.PrimaryExpressionAttr(relvarattr), exp)
})
}
}
- def addExpr(binding:FullOrPartialBinding, relAliasAttr:sql.RelAliasAttribute, expr:sql.RelationalExpression):FullOrPartialBinding = {
+ def addExpr(binding:FullOrPartialBinding, relVarAttr:sql.RelVarAttr, expr:sql.RelationalExpression):FullOrPartialBinding = {
binding match {
- case FullBinding(relaliasattr) =>
+ case FullBinding(relvarattr) =>
binding
case PartialBinding(binders) =>
- PartialBinding(binders + BindingConstraint(expr, relAliasAttr))
+ PartialBinding(binders + BindingConstraint(expr, relVarAttr))
}
}
- def toConstraint999(constrainMe:sql.RelAliasAttribute, against:FullOrPartialBinding):sql.Expression = {
+ def toConstraint999(constrainMe:sql.RelVarAttr, against:FullOrPartialBinding):sql.Expression = {
against match {
- case FullBinding(relaliasattr) =>
+ case FullBinding(relvarattr) =>
sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(constrainMe),
- sql.PrimaryExpressionAttr(relaliasattr))
+ sql.PrimaryExpressionAttr(relvarattr))
case PartialBinding(binders) =>
sql.ExprConjunction({binders.map(b => {
- val BindingConstraint(expr, relaliasattr) = b
+ val BindingConstraint(expr, relvarattr) = b
sql.ExprDisjunction(Set(expr,
sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(constrainMe),
- sql.PrimaryExpressionAttr(relaliasattr))))})})
+ sql.PrimaryExpressionAttr(relvarattr))))})})
}
}
@@ -74,7 +74,7 @@
case class RDFNoder(relation:sql.Relation, binding:FullOrPartialBinding) extends SQL2RDFValueMapper(binding)
case class RDFBNoder(relation:sql.Relation, binding:FullOrPartialBinding) extends SQL2RDFValueMapper(binding)
- case class ObjUri(stem:Stem, rel:Rel, attr:Attr, v:CellValue)
+ case class NodeUri(stem:Stem, rel:Rel, attr:Attr, v:CellValue)
case class Stem(s:String) {
override def toString = "" + s
}
@@ -99,7 +99,7 @@
}
/* stemURI + '/' (\w+) '/' (\w+) '.' (\w+) '#record' */
- def parseObjectURI(u:sparql.Uri):ObjUri = {
+ def parseObjectURI(u:sparql.Uri):NodeUri = {
val x:String = u.s
val uri = new URI(x)
val path = uri.getPath().split("/").toList.filterNot(_ == "")
@@ -108,47 +108,47 @@
val attrPair = path(path.size-1).split("\\.")
val stem = uri.getScheme() + "://" + uri.getAuthority + "/" + subPath
assert("record" == uri.getFragment)
- ObjUri(Stem(stem), Rel(rel), Attr(attrPair(0)), CellValue(attrPair(1)))
+ NodeUri(Stem(stem), Rel(rel), Attr(attrPair(0)), CellValue(attrPair(1)))
}
/*
Sparql.parseObjectURI(
Sparql.parsePredicateURI(
*/
- def relAliasFromS(s:sparql.S):sql.RelAlias = {
+ def relVarFromS(s:sparql.S):sql.RelVar = {
s match {
- case sparql.SUri(ob) => relAliasFromNode(ob)
- case sparql.SVar(v) => relAliasFromVar(v)
+ case sparql.SUri(ob) => relVarFromNode(ob)
+ case sparql.SVar(v) => relVarFromVar(v)
}
}
- def relAliasFromO(o:sparql.O):sql.RelAlias = {
+ def relVarFromO(o:sparql.O):sql.RelVar = {
o match {
- case sparql.OUri(ob) => relAliasFromNode(ob)
- case sparql.OVar(v) => relAliasFromVar(v)
- case sparql.OLit(l) => relAliasFromLiteral(l)
+ case sparql.OUri(ob) => relVarFromNode(ob)
+ case sparql.OVar(v) => relVarFromVar(v)
+ case sparql.OLit(l) => relVarFromLiteral(l)
}
}
- def relAliasFromNode(u:sparql.Uri):sql.RelAlias = {
- val ObjUri(stem, rel, Attr(a), CellValue(v)) = parseObjectURI(u)
- sql.RelAlias(sql.Name("R_" + a + v))
+ def relVarFromNode(u:sparql.Uri):sql.RelVar = {
+ val NodeUri(stem, rel, Attr(a), CellValue(v)) = parseObjectURI(u)
+ sql.RelVar(sql.Name("R_" + a + v))
}
- def relAliasFromLiteral(l:sparql.Literal):sql.RelAlias = {
- sql.RelAlias(sql.Name("R_" + l.lit.lexicalForm))
+ def relVarFromLiteral(l:sparql.Literal):sql.RelVar = {
+ sql.RelVar(sql.Name("R_" + l.lit.lexicalForm))
}
- def relAliasFromVar(vr:sparql.Var):sql.RelAlias = {
+ def relVarFromVar(vr:sparql.Var):sql.RelVar = {
val sparql.Var(v) = vr
- sql.RelAlias(sql.Name("R_" + v))
+ sql.RelVar(sql.Name("R_" + v))
}
def attrAliasNameFromVar(v:sparql.Var):sql.Name = sql.Name("" + v.s)
- def uriConstraint(state:R2RState, constrainMe:sql.RelAliasAttribute, u:ObjUri, enforeForeignKeys:Boolean):R2RState = {
+ def uriConstraint(state:R2RState, constrainMe:sql.RelVarAttr, u:NodeUri, enforeForeignKeys:Boolean):R2RState = {
val relvar =
if (enforeForeignKeys)
- sql.RelAliasAttribute(constrainMe.relalias, sql.Attribute(sql.Name(u.attr.s)))
+ sql.RelVarAttr(constrainMe.relvar, sql.Attribute(sql.Name(u.attr.s)))
else
constrainMe
R2RState(state.joins,
@@ -157,7 +157,7 @@
sql.PrimaryExpressionTyped(sql.Datatype.INTEGER,sql.Name(u.v.s))))
}
- def literalConstraint(state:R2RState, constrainMe:sql.RelAliasAttribute, lit:sparql.Literal, dt:sql.Datatype):R2RState = {
+ def literalConstraint(state:R2RState, constrainMe:sql.RelVarAttr, lit:sparql.Literal, dt:sql.Datatype):R2RState = {
R2RState(state.joins,
state.varmap,
state.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(constrainMe),
@@ -175,12 +175,12 @@
* type String -> RDFStringConstructor // adds ^^xsd:string
* type primary key -> RDFNodeConstructor // prefixes with stemURL + relation + attribute and adds #record
* */
- def varConstraint(state:R2RState, alias:sql.RelAlias, optAttr:Option[sql.Attribute], v:sparql.Var, db:sql.DatabaseDesc, rel:sql.Relation):R2RState = {
+ def varConstraint(state:R2RState, alias:sql.RelVar, optAttr:Option[sql.Attribute], v:sparql.Var, db:sql.DatabaseDesc, rel:sql.Relation):R2RState = {
/* e.g. Employee _emp.id
** Employee _emp.lastName
** Employee _emp.manager
*/
- val constrainMe = if (optAttr.isDefined) sql.RelAliasAttribute(alias, optAttr.get) else sql.RelAliasAttribute(alias, sql.Attribute(sql.Name("_no_such_attribute")))
+ val constrainMe = if (optAttr.isDefined) sql.RelVarAttr(alias, optAttr.get) else sql.RelVarAttr(alias, sql.Attribute(sql.Name("_no_such_attribute")))
val reldesc = db.relationdescs(rel)
val boundTo = FullBinding(constrainMe)
val binding = reldesc.primarykey match {
@@ -217,21 +217,21 @@
}
}
- def toString(relaliasattr:sql.RelAliasAttribute) : String = {
- relaliasattr.relalias.n.s + "." + relaliasattr.attribute.n.s
+ def toString(relvarattr:sql.RelVarAttr) : String = {
+ relvarattr.relvar.n.s + "." + relvarattr.attribute.n.s
}
// def toString(mapper:SQL2RDFValueMapper) : String = {
// mapper match {
- // case IntMapper(relalias, disjoints) => "INT: " + toString(relalias)
- // case StringMapper(relalias, disjoints) => "STRING: " + toString(relalias)
- // case DateMapper(relalias, disjoints) => "DATE: " + toString(relalias)
- // case RDFNoder(relation, relalias, disjoints) => "RDFNoder: " + relation.n.s + ", " + toString(relalias)
- // case RDFBNoder(relation, relalias, disjoints) => "RDFBNoder: " + relation.n.s + ", " + toString(relalias)
+ // case IntMapper(relvar, disjoints) => "INT: " + toString(relvar)
+ // case StringMapper(relvar, disjoints) => "STRING: " + toString(relvar)
+ // case DateMapper(relvar, disjoints) => "DATE: " + toString(relvar)
+ // case RDFNoder(relation, relvar, disjoints) => "RDFNoder: " + relation.n.s + ", " + toString(relvar)
+ // case RDFBNoder(relation, relvar, disjoints) => "RDFBNoder: " + relation.n.s + ", " + toString(relvar)
// }
// }
/* bindOnPredicate: map a given triple to one or two joined tables, variable
- * bindings to RelVarAttributes, and constraints if those variables were
+ * bindings to RelVarAttrs, and constraints if those variables were
* already bound. */
def bindOnPredicate(db:sql.DatabaseDesc, stateP:R2RState, triple:sparql.TriplePattern, enforceForeignKeys:Boolean):R2RState = {
val sparql.TriplePattern(s, p, o) = triple
@@ -242,21 +242,21 @@
/* Attributes that come from the predicate: */
val rel = sql.Relation(sql.Name(spRel.s))
val attr = sql.Attribute(sql.Name(spAttr.s))
- val relalias = relAliasFromS(s)
+ val relvar = relVarFromS(s)
/* Attributes that come from the subject: */
- val objattr = sql.RelAliasAttribute(relalias, attr)
+ val objattr = sql.RelVarAttr(relvar, attr)
val state_postSubj = s match {
- case sparql.SUri(u) => uriConstraint(stateP, sql.RelAliasAttribute(relalias, db.relationdescs(rel).primarykey.get), parseObjectURI(u), true)
- case sparql.SVar(v) => varConstraint(stateP, relalias, db.relationdescs(rel).primarykey, v, db, rel)
+ case sparql.SUri(u) => uriConstraint(stateP, sql.RelVarAttr(relvar, db.relationdescs(rel).primarykey.get), parseObjectURI(u), true)
+ case sparql.SVar(v) => varConstraint(stateP, relvar, db.relationdescs(rel).primarykey, v, db, rel)
}
- val state_subjJoin = R2RState(state_postSubj.joins + sql.InnerJoin(sql.AliasedResource(rel,relalias), None), state_postSubj.varmap, state_postSubj.exprs)
+ val state_subjJoin = R2RState(state_postSubj.joins + sql.InnerJoin(sql.AliasedResource(rel,relvar), None), state_postSubj.varmap, state_postSubj.exprs)
try { db.relationdescs(rel).attributes(attr) } catch {
case e:java.util.NoSuchElementException =>
throw new Exception("error processing { " + s + " " + p + " " + o + " } :db.relationdescs(" + rel + ").attributes(" + attr + ") not found in " + db)
}
- val (targetattr:sql.RelAliasAttribute, targetrel, dt, state_fkeys:R2RState) = db.relationdescs(rel).attributes(attr) match {
+ val (targetattr:sql.RelVarAttr, targetrel, dt, state_fkeys:R2RState) = db.relationdescs(rel).attributes(attr) match {
case sql.ForeignKey(fkrel, fkattr) => {
try { db.relationdescs(fkrel).attributes(fkattr) } catch {
case e:java.util.NoSuchElementException =>
@@ -269,9 +269,9 @@
case sql.Value(x) => x
}
if (enforceForeignKeys) {
- val oRelAlias = relAliasFromO(o)
- val fkaliasattr = sql.RelAliasAttribute(oRelAlias, fkattr)
- val state_t = R2RState(state_subjJoin.joins + sql.InnerJoin(sql.AliasedResource(fkrel,oRelAlias), None),
+ val oRelVar = relVarFromO(o)
+ val fkaliasattr = sql.RelVarAttr(oRelVar, fkattr)
+ val state_t = R2RState(state_subjJoin.joins + sql.InnerJoin(sql.AliasedResource(fkrel,oRelVar), None),
state_subjJoin.varmap,
state_subjJoin.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(fkaliasattr),
sql.PrimaryExpressionAttr(objattr)))
@@ -286,7 +286,7 @@
o match {
case sparql.OLit(l) => literalConstraint(state_fkeys, targetattr, l, dt)
case sparql.OUri(u) => uriConstraint (state_fkeys, targetattr, parseObjectURI(u), enforceForeignKeys)
- case sparql.OVar(v) => varConstraint (state_fkeys, targetattr.relalias, Some(targetattr.attribute), v, db, targetrel)
+ case sparql.OVar(v) => varConstraint (state_fkeys, targetattr.relvar, Some(targetattr.attribute), v, db, targetrel)
}
}
}
@@ -326,33 +326,33 @@
}
}
- def bindingConstraintToAttribute(constraint:BindingConstraint):sql.RelAliasAttribute = {
- val BindingConstraint(expr:sql.RelationalExpression, relaliasattr:sql.RelAliasAttribute) = constraint;
- relaliasattr
+ def bindingConstraintToAttribute(constraint:BindingConstraint):sql.RelVarAttr = {
+ val BindingConstraint(expr:sql.RelationalExpression, relvarattr:sql.RelVarAttr) = constraint;
+ relvarattr
}
- def bindingToAttribute(binding:FullOrPartialBinding):sql.RelAliasAttribute = {
+ def bindingToAttribute(binding:FullOrPartialBinding):sql.RelVarAttr = {
binding match {
- case FullBinding(relaliasattr:sql.RelAliasAttribute) => relaliasattr
+ case FullBinding(relvarattr:sql.RelVarAttr) => relvarattr
case PartialBinding(binders) => bindingConstraintToAttribute(binders.toList(0))
}
}
- def varToAttribute(varmap:Map[sparql.Var, SQL2RDFValueMapper], vvar:sparql.Var):sql.RelAliasAttribute = {
+ def varToAttribute(varmap:Map[sparql.Var, SQL2RDFValueMapper], vvar:sparql.Var):sql.RelVarAttr = {
varmap(vvar) match {
case IntMapper(binding) => bindingToAttribute(binding)
case StringMapper(binding) => bindingToAttribute(binding)
case DateMapper(binding) => bindingToAttribute(binding)
case RDFNoder(relation, binding) => bindingToAttribute(binding)
- case RDFBNoder(relation, binding) => bindingToAttribute(binding) // error("BNode should not need relalias " + relalias)
+ case RDFBNoder(relation, binding) => bindingToAttribute(binding) // error("BNode should not need relvar " + relvar)
}
}
def bindingConstraintToExpression(constraint:BindingConstraint):sql.RelationalExpression = {
- val BindingConstraint(expr:sql.RelationalExpression, relaliasattr:sql.RelAliasAttribute) = constraint;
+ val BindingConstraint(expr:sql.RelationalExpression, relvarattr:sql.RelVarAttr) = constraint;
expr
}
def bindingToDisjoints(binding:FullOrPartialBinding):Set[sql.RelationalExpression] = {
binding match {
- case FullBinding(relaliasattr:sql.RelAliasAttribute) => Set[sql.RelationalExpression]()
+ case FullBinding(relvarattr:sql.RelVarAttr) => Set[sql.RelationalExpression]()
case PartialBinding(binders) => binders.map({b => bindingConstraintToExpression(b)})
}
}
@@ -362,7 +362,7 @@
case StringMapper(binding) => bindingToDisjoints(binding)
case DateMapper(binding) => bindingToDisjoints(binding)
case RDFNoder(relation, binding) => bindingToDisjoints(binding)
- case RDFBNoder(relation, binding) => bindingToDisjoints(binding) // error("BNode should not need relalias " + relalias)
+ case RDFBNoder(relation, binding) => bindingToDisjoints(binding) // error("BNode should not need relvar " + relvar)
}
}
@@ -394,7 +394,7 @@
}
def filter2expr(varmap:Map[sparql.Var, SQL2RDFValueMapper], f:sparql.PrimaryExpression):sql.RelationalExpression = {
- val (lTerm:sparql.Term, rTerm:sparql.Term, sqlexpr) = f match { // sqlexpr::((sql.RelAliasAttribute,sql.PrimaryExpressionAttr)=>sql.RelationalExpression)
+ val (lTerm:sparql.Term, rTerm:sparql.Term, sqlexpr) = f match { // sqlexpr::((sql.RelVarAttr,sql.PrimaryExpressionAttr)=>sql.RelationalExpression)
case sparql.PrimaryExpressionEq(l, r) => (l.term, r.term, sql.RelationalExpressionEq(_,_))
case sparql.PrimaryExpressionLt(l, r) => (l.term, r.term, sql.RelationalExpressionLt(_,_))
}
@@ -423,12 +423,12 @@
* outer varmap/expressions.
* <outerState> could be <myState> -- spliting roles could make proofs easier?
*/
- def subselectVars(myState:R2RState, v:sparql.Var, optionalAlias:sql.RelAlias,
+ def subselectVars(myState:R2RState, v:sparql.Var, optionalAlias:sql.RelVar,
optionalCond:sql.RelationalExpression,
outerVarmap:Map[sparql.Var, SQL2RDFValueMapper],
nestedVarmap:Map[sparql.Var, SQL2RDFValueMapper],
isOpt:Boolean):R2RState = {
- val varAliasAttr = sql.RelAliasAttribute(optionalAlias, sql.Attribute(attrAliasNameFromVar(v)))
+ val varAliasAttr = sql.RelVarAttr(optionalAlias, sql.Attribute(attrAliasNameFromVar(v)))
if (myState.varmap.contains(v)) {
/* The variable has already been bound. */
val newMap:Map[sparql.Var, SQL2RDFValueMapper] = if (varToAttribute(myState.varmap, v) == varAliasAttr) {
@@ -480,7 +480,7 @@
/* SPARQL OPTIONALs are treated as SQL subselects.
* Set up initial state for this subselect.
*/
- val leftJoinAlias = sql.RelAlias(sql.Name("G_opt" + initState.joins.size))
+ val leftJoinAlias = sql.RelVar(sql.Name("G_opt" + initState.joins.size))
val initDisjoints:Set[sql.Select] = Set()
val emptyState = R2RState(
util.AddOrderedSet[sql.Join](),
@@ -512,7 +512,7 @@
* _DISJOINT_ as OPTIONAL behaves pretty much like a disjunction).
*/
val optionalCond = sql.RelationalExpressionNull(sql.PrimaryExpressionAttr(
- sql.RelAliasAttribute(leftJoinAlias, sql.Attribute(sql.Name("_DISJOINT_")))))
+ sql.RelVarAttr(leftJoinAlias, sql.Attribute(sql.Name("_DISJOINT_")))))
/* Bind variables to the attributes projected from the subselect; handle
* corefs (equivalence with earlier bindings).
@@ -544,7 +544,7 @@
)
val exprs =
if (negate) {
- initState.exprs + sql.RelationalExpressionNull(sql.PrimaryExpressionAttr(sql.RelAliasAttribute(leftJoinAlias, sql.Attribute(sql.Name("_DISJOINT_")))))
+ initState.exprs + sql.RelationalExpressionNull(sql.PrimaryExpressionAttr(sql.RelVarAttr(leftJoinAlias, sql.Attribute(sql.Name("_DISJOINT_")))))
} else initState.exprs
R2RState(initState.joins + join, outerState2.varmap, exprs)
}
@@ -578,7 +578,7 @@
/* SPARQL UNIONs are treated as SQL subselects.
* Set up initial state for this subselect.
*/
- val unionAlias = sql.RelAlias(sql.Name("G_union" + state.joins.size))
+ val unionAlias = sql.RelVar(sql.Name("G_union" + state.joins.size))
val emptyState = R2RState(
util.AddOrderedSet[sql.Join](),
Map[sparql.Var, SQL2RDFValueMapper](),
@@ -628,7 +628,7 @@
/* Create a condition to test if this OPTIONAL was matched (called
* _DISJOINT_ as OPTIONAL behaves pretty much like a disjunction).
*/
- val disjointCond = sql.RelationalExpressionNe(sql.PrimaryExpressionAttr(sql.RelAliasAttribute(unionAlias, sql.Attribute(sql.Name("_DISJOINT_")))),
+ val disjointCond = sql.RelationalExpressionNe(sql.PrimaryExpressionAttr(sql.RelVarAttr(unionAlias, sql.Attribute(sql.Name("_DISJOINT_")))),
sql.PrimaryExpressionTyped(sql.Datatype.INTEGER,sql.Name("" + no)))
val outerState2 = disjointVars.foldLeft(outerState)((myState, v) =>
subselectVars(myState, v, unionAlias, disjointCond, outerState.varmap, disjointState.varmap, false))
@@ -649,7 +649,7 @@
sql.AttrAlias(sql.Name("_EMPTY_"))))),
sql.TableList(util.AddOrderedSet()),
None
- )), sql.RelAlias(sql.Name("_EMPTY_"))), None), state.varmap, state.exprs)
+ )), sql.RelVar(sql.Name("_EMPTY_"))), None), state.varmap, state.exprs)
else
state
synthesizeOuterJoin(state_postLeadingTable, gp, false, db, enforceForeignKeys)
--- a/src/test/scala/SQLTest.scala Sun Jan 31 09:32:43 2010 -0500
+++ b/src/test/scala/SQLTest.scala Sun Jan 31 10:39:08 2010 -0500
@@ -7,49 +7,49 @@
class SQLTest extends FunSuite {
test("parse ANDexpression") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
R_manager.id=R_emp.manager AND R_emp.lastName IS NOT NULL AND R_manager.lastName IS NOT NULL
"""
val expected = ExprConjunction(Set(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))
assert(expected === (a.parseAll(a.expression, e).get))
}
test("parse ORexpression") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
R_manager.id=R_emp.manager OR R_emp.lastName IS NOT NULL OR R_manager.lastName IS NOT NULL
"""
val expected = ExprDisjunction(Set(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))
assert(expected === (a.parseAll(a.expression, e).get))
}
test("parse nested expression") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
( R_manager.id=R_emp.manager OR R_emp.lastName IS NOT NULL OR R_manager.lastName IS NOT NULL )
"""
val expected = ExprDisjunction(Set(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))
assert(expected === (a.parseAll(a.expression, e).get))
}
test("parse no FROM") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
SELECT 1 AS _TEST_
@@ -62,7 +62,7 @@
}
test("parse WHERE") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
SELECT R_emp.lastName AS A_empName
@@ -70,38 +70,38 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.id=R_emp.manager
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
Some(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))))
assert(expected === (a.parseAll(a.select, e).get))
}
test("parse INNER JOIN ON") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
SELECT R_emp.lastName AS A_empName
FROM Employee AS R_emp
INNER JOIN Employee AS R_manager ON R_manager.id=R_emp.manager
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
Some(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))))))
assert(expected === (a.parseAll(a.select, e).get))
}
test("parse SQLbgp") {
- // AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))
+ // AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp")))
val a = Sql()
val e = """
SELECT R_emp.lastName AS A_empName, R_manager.lastName AS A_managName
@@ -109,19 +109,19 @@
INNER JOIN Employee AS R_manager
WHERE R_manager.id=R_emp.manager AND R_emp.lastName IS NOT NULL AND R_manager.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_manager")),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_manager")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_managName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
Some(ExprConjunction(Set(
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))))))))
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -132,13 +132,13 @@
FROM Employee AS R_emp
WHERE R_emp.manager=18 AND R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
PrimaryExpressionTyped(Datatype.INTEGER,Name("18"))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))))
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -150,16 +150,16 @@
INNER JOIN Employee AS R_manager
WHERE R_emp.manager=R_manager.id AND R_manager.lastName="Johnson" AND R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName")))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("manager")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName")))),
PrimaryExpressionTyped(Datatype.STRING,Name("Johnson"))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))))
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -178,29 +178,29 @@
AND R_grandManager.birthday < R_manager.birthday
AND R_emp.lastName IS NOT NULL AND R_grandManager.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")), Attribute(Name("lastName"))),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")), Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("lastName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName"))),
AttrAlias(Name("A_grandManagName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_lower"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_upper"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_grandManager"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_lower")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_lower")),Attribute(Name("manager"))))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("birthday")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("birthday"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_upper")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("id")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_upper")),Attribute(Name("manager"))))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("birthday")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("birthday"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("lastName")))))))))
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_lower"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_upper"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_grandManager"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_lower")),Attribute(Name("manager"))))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("birthday"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_upper")),Attribute(Name("manager"))))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("birthday")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("birthday"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_grandManager")),Attribute(Name("lastName")))))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -222,36 +222,36 @@
) AS R_union1
WHERE R_union1.A_who=R_who.id AND R_who.lastName="Smith"
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_union1")), Attribute(Name("name"))),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_union1")), Attribute(Name("name"))),
AttrAlias(Name("A_name"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_who"))), None),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_who"))), None),
InnerJoin(AliasedResource(Subselect(Union(Set(
- Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_manager")), Attribute(Name("lastName"))),
+ Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_manager")), Attribute(Name("lastName"))),
AttrAlias(Name("A_name"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_above")), Attribute(Name("manages"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_above")), Attribute(Name("manages"))),
AttrAlias(Name("A_who"))))),
TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None)
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_manager"))), None)
)),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("manager")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("lastName"))))))))),
- Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_managed")), Attribute(Name("lastName"))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("manager")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("id"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_manager")),Attribute(Name("lastName"))))))))),
+ Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_managed")), Attribute(Name("lastName"))),
AttrAlias(Name("A_name"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_below")), Attribute(Name("manager"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_below")), Attribute(Name("manager"))),
AttrAlias(Name("A_who"))))),
TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_below"))), None),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_managed"))), None)
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_below"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_managed"))), None)
)),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_below")),Attribute(Name("manages")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_managed")),Attribute(Name("id"))))),
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_managed")),Attribute(Name("lastName")))))))))))),
- RelAlias(Name("R_union1"))), None))),
- Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_union1")),Attribute(Name("A_who")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_who")),Attribute(Name("id"))))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_who")),Attribute(Name("lastName")))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_below")),Attribute(Name("manages")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("id"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_managed")),Attribute(Name("lastName")))))))))))),
+ RelVar(Name("R_union1"))), None))),
+ Some(ExprConjunction(Set(RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_union1")),Attribute(Name("A_who")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("id"))))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_who")),Attribute(Name("lastName")))),
PrimaryExpressionTyped(Datatype.STRING,Name("Smith")))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -263,14 +263,14 @@
FROM Manage AS R_above
WHERE R_above.id IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_above")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
Attribute(Name("manages"))),
AttrAlias(Name("A_who"))),
NamedAttribute(ConstNULL(),
AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
Some(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))))))
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))))))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -286,10 +286,10 @@
PrimaryExpressionTyped(Datatype("String"),Name("/")),
PrimaryExpressionTyped(Datatype("String"),Name("id")),
PrimaryExpressionTyped(Datatype("String"),Name(".")),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("id")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))),
PrimaryExpressionTyped(Datatype("String"),Name("#record")))),
AttrAlias(Name("A_emp"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -301,19 +301,19 @@
FROM Manage AS R_above
WHERE (R_above.id IS NOT NULL) OR (R_above.id < 5 AND R_above.id < 3)
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_above")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_above")),
Attribute(Name("manages"))),
AttrAlias(Name("A_who"))),
NamedAttribute(ConstNULL(),
AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_above"))), None))),
Some(
ExprDisjunction(Set(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id"))))),
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id"))))),
ExprConjunction(Set(
- RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
PrimaryExpressionTyped(Datatype.INTEGER,Name("5"))),
- RelationalExpressionLt(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))),
+ RelationalExpressionLt(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_above")),Attribute(Name("id")))),
PrimaryExpressionTyped(Datatype.INTEGER,Name("3")))
))))))
assert(expected === (a.parseAll(a.select, e).get))
@@ -327,19 +327,19 @@
LEFT OUTER JOIN Manage AS R_mang ON R_mang.emp=R_emp.id
WHERE R_emp.lastName IS NOT NULL
"""
- val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
+ val expected = Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_mang")),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),
Attribute(Name("manageName"))),
AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
- LeftOuterJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_mang"))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_mang")),Attribute(Name("emp")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("id"))))
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
+ LeftOuterJoin(AliasedResource(Relation(Name("Manage")),RelVar(Name("R_mang"))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id"))))
)))),
Some(
- RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))
+ RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))
))
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -356,18 +356,18 @@
WHERE R_emp.lastName IS NOT NULL
"""
val expected =
- Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
+ Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None),
LeftOuterJoin(AliasedResource(
- Subselect(Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
- NamedAttribute(RelAliasAttribute(RelAlias(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None))),
+ Subselect(Select(AttributeList(Set(NamedAttribute(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName"))),AttrAlias(Name("A_empName"))),
+ NamedAttribute(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("manageName"))),AttrAlias(Name("A_manageName"))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelVar(Name("R_emp"))), None))),
None)),
- RelAlias(Name("R_mang"))),
- RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_mang")),Attribute(Name("emp")))),
- PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("id")))))))),
- Some(RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))
+ RelVar(Name("R_mang"))),
+ RelationalExpressionEq(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_mang")),Attribute(Name("emp")))),
+ PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("id")))))))),
+ Some(RelationalExpressionNotNull(PrimaryExpressionAttr(RelVarAttr(RelVar(Name("R_emp")),Attribute(Name("lastName")))))))
assert(expected === (a.parseAll(a.select, e).get))
}