--- a/src/main/scala/RDB2RDFMain.scala Sat Jan 09 00:49:31 2010 -0500
+++ b/src/main/scala/RDB2RDFMain.scala Sat Jan 09 10:37:57 2010 -0500
@@ -173,13 +173,13 @@
case sparql.SUri(u) => uriConstraint(stateP, sql.RelAliasAttribute(relalias, db.relationdescs(rel).primarykey.get), u, true)
case sparql.SVar(v) => varConstraint(stateP, relalias, db.relationdescs(rel).primarykey, v, db, rel)
}
- val state_subjJoin = R2RState(state_postSubj.joins + sql.InnerJoin(sql.AliasedResource(rel,relalias)), state_postSubj.varmap, state_postSubj.exprs)
+ val state_subjJoin = R2RState(state_postSubj.joins + sql.InnerJoin(sql.AliasedResource(rel,relalias), 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, targetrel, dt, state_fkeys:R2RState) = db.relationdescs(rel).attributes(attr) match {
+ val (targetattr:sql.RelAliasAttribute, 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 =>
@@ -194,7 +194,7 @@
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)),
+ val state_t = R2RState(state_subjJoin.joins + sql.InnerJoin(sql.AliasedResource(fkrel,oRelAlias), None),
state_subjJoin.varmap,
state_subjJoin.exprs + sql.RelationalExpressionEq(sql.PrimaryExpressionAttr(fkaliasattr),
sql.PrimaryExpressionAttr(objattr)))
@@ -449,7 +449,7 @@
(outerState2, no+1)
})
val subselect = sql.Subselect(sql.Union(subselects))
- R2RState(state.joins + sql.InnerJoin(sql.AliasedResource(subselect,unionAlias)), state2.varmap, state2.exprs)
+ R2RState(state.joins + sql.InnerJoin(sql.AliasedResource(subselect,unionAlias), None), state2.varmap, state2.exprs)
}
case sparql.OptionalGraphPattern(gp) => {
/* state_postLeadingTable: create an initial table if the first conjoint is optional.
@@ -463,7 +463,7 @@
sql.AttrAlias(sql.Name("_EMPTY_"))))),
sql.TableList(util.AddOrderedSet()),
None
- )), sql.RelAlias(sql.Name("_EMPTY_")))), state.varmap, state.exprs)
+ )), sql.RelAlias(sql.Name("_EMPTY_"))), None), state.varmap, state.exprs)
else
state
--- a/src/test/scala/SQLTest.scala Sat Jan 09 00:49:31 2010 -0500
+++ b/src/test/scala/SQLTest.scala Sat Jan 09 10:37:57 2010 -0500
@@ -73,8 +73,8 @@
val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
Some(
RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))))))
@@ -92,8 +92,8 @@
val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))), None))),
Some(
RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id")))),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager")))))))
@@ -115,8 +115,8 @@
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_manager")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_managName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager")))))),
+ 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_manager")),Attribute(Name("id")))),
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))))),
@@ -135,7 +135,7 @@
val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))))),
+ 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")))),
PrimaryExpressionTyped(Datatype.INTEGER,Name("18"))),
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))))
@@ -153,8 +153,8 @@
val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager")))))),
+ 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")))),
@@ -182,11 +182,11 @@
AttrAlias(Name("A_empName"))),
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("lastName"))),
AttrAlias(Name("A_grandManagName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_lower")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager")))),
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_upper")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_grandManager")))))),
+ 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")))),
@@ -224,15 +224,15 @@
"""
val expected = Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_union1")), Attribute(Name("name"))),
AttrAlias(Name("A_name"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_who")))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_who"))), None),
InnerJoin(AliasedResource(Subselect(Union(Set(
Select(AttributeList(Set(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_manager")), Attribute(Name("lastName"))),
AttrAlias(Name("A_name"))),
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_above")), Attribute(Name("manages"))),
AttrAlias(Name("A_who"))))),
TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))))
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(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"))))),
@@ -242,13 +242,13 @@
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_below")), Attribute(Name("manager"))),
AttrAlias(Name("A_who"))))),
TableList(AddOrderedSet(
- InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_below")))),
- InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_managed"))))
+ InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_below"))), None),
+ InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(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")))))),
+ 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")))),
@@ -268,7 +268,7 @@
AttrAlias(Name("A_who"))),
NamedAttribute(ConstNULL(),
AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None))),
Some(
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id")))))))
assert(expected === (a.parseAll(a.select, e).get))
@@ -289,7 +289,7 @@
PrimaryExpressionAttr(RelAliasAttribute(RelAlias(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")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None))),
None)
assert(expected === (a.parseAll(a.select, e).get))
}
@@ -306,7 +306,7 @@
AttrAlias(Name("A_who"))),
NamedAttribute(ConstNULL(),
AttrAlias(Name("A_bday"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_above"))), None))),
Some(
ExprDisjunction(Set(
RelationalExpressionNotNull(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_above")),Attribute(Name("id"))))),
@@ -333,7 +333,7 @@
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_mang")),
Attribute(Name("manageName"))),
AttrAlias(Name("A_manageName"))))),
- TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp")))),
+ 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"))))
@@ -358,11 +358,11 @@
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")))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(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")))))),
+ TableList(AddOrderedSet(InnerJoin(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))), None))),
None)),
RelAlias(Name("R_mang"))),
RelationalExpressionEq(PrimaryExpressionAttr(RelAliasAttribute(RelAlias(Name("R_mang")),Attribute(Name("emp")))),