~ prefix synthesized tables with G_ (for "Generated")
authorEric Prud'hommeaux <eric@w3.org>
Thu, 07 Jan 2010 23:38:58 -0500
changeset 129 15ac503279d2
parent 128 d9720946cb51
child 130 e5d71f322f9d
~ prefix synthesized tables with G_ (for "Generated")
src/main/scala/RDB2RDFMain.scala
src/test/scala/RDB2RDFTest.scala
--- a/src/main/scala/RDB2RDFMain.scala	Thu Jan 07 23:31:54 2010 -0500
+++ b/src/main/scala/RDB2RDFMain.scala	Thu Jan 07 23:38:58 2010 -0500
@@ -347,7 +347,7 @@
 	/* SPARQL UNIONs are treated as SQL subselects.
 	 * Set up initial state for this subselect.
 	 */
-	val unionAlias = sql.RelAlias(sql.Name("R_union" + state.joins.size))
+	val unionAlias = sql.RelAlias(sql.Name("G_union" + state.joins.size))
 	val emptyState = R2RState(
 	  util.AddOrderedSet[sql.Join](), 
 	  Map[sparql.Var, SQL2RDFValueMapper](), 
@@ -467,7 +467,7 @@
 	/* SPARQL OPTIONALs are treated as SQL subselects.
 	 * Set up initial state for this subselect.
 	 */
-      	val leftJoinAlias = sql.RelAlias(sql.Name("R_opt" + state_postLeadingTable.joins.size))
+      	val leftJoinAlias = sql.RelAlias(sql.Name("G_opt" + state_postLeadingTable.joins.size))
       	val initDisjoints:Set[sql.Select] = Set()
       	val emptyState = R2RState(
       	  util.AddOrderedSet[sql.Join](), 
--- a/src/test/scala/RDB2RDFTest.scala	Thu Jan 07 23:31:54 2010 -0500
+++ b/src/test/scala/RDB2RDFTest.scala	Thu Jan 07 23:38:58 2010 -0500
@@ -305,7 +305,7 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_union1.A_name AS A_name
+SELECT G_union1.A_name AS A_name
   FROM Employee AS R_who
        INNER JOIN (
          SELECT 0 AS _DISJOINT_, R_above.id AS A_above, R_above.task AS A_atask,
@@ -330,11 +330,11 @@
           WHERE R_below.employee IS NOT NULL AND R_managed.lastName IS NOT NULL
             AND R_below.task IS NOT NULL AND R_btask.lead IS NOT NULL
             AND R_below.id IS NOT NULL
-                       ) AS R_union1
+                       ) AS G_union1
  WHERE R_who.lastName="Smith"
        AND R_who.empid IS NOT NULL
-       AND (R_union1._DISJOINT_!=0 OR R_union1.A_who=R_who.empid)
-       AND (R_union1._DISJOINT_!=1 OR R_union1.A_who=R_who.empid)
+       AND (G_union1._DISJOINT_!=0 OR G_union1.A_who=R_who.empid)
+       AND (G_union1._DISJOINT_!=1 OR G_union1.A_who=R_who.empid)
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
     assert(transformed === parsed)
@@ -363,7 +363,7 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_union0.A_name AS A_name
+SELECT G_union0.A_name AS A_name
   FROM (
          SELECT R_above.id AS A_above, R_above.task AS A_atask, NULL AS A_bday, NULL AS A_below,
                 NULL AS A_btask, NULL AS A_managed, R_taskLead.lastName AS A_name,
@@ -382,12 +382,12 @@
                 INNER JOIN Employee AS R_managed ON R_managed.empid=R_below.employee
           WHERE R_below.employee IS NOT NULL AND R_below.id IS NOT NULL AND R_below.task IS NOT NULL
             AND R_btask.lead IS NOT NULL AND R_managed.birthday IS NOT NULL AND R_managed.lastName IS NOT NULL
-                  ) AS R_union0
+                  ) AS G_union0
        INNER JOIN Employee AS R_who
- WHERE (R_union0._DISJOINT_!=0 OR R_who.empid=R_union0.A_who)
-   AND (R_union0._DISJOINT_!=1 OR R_who.birthday=R_union0.A_bday)
-   AND (R_union0._DISJOINT_!=1 OR R_who.empid=R_union0.A_who)
-   AND R_union0.A_bday IS NOT NULL AND R_union0.A_who IS NOT NULL AND R_who.lastName="Smith"
+ WHERE (G_union0._DISJOINT_!=0 OR R_who.empid=G_union0.A_who)
+   AND (G_union0._DISJOINT_!=1 OR R_who.birthday=G_union0.A_bday)
+   AND (G_union0._DISJOINT_!=1 OR R_who.empid=G_union0.A_who)
+   AND G_union0.A_bday IS NOT NULL AND G_union0.A_who IS NOT NULL AND R_who.lastName="Smith"
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
     assert(transformed === parsed)
@@ -418,7 +418,7 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_union1.A_name AS A_name
+SELECT G_union1.A_name AS A_name
   FROM Employee AS R_who
        INNER JOIN (
          SELECT R_above.id AS A_above, R_above.task AS A_atask, NULL AS A_bday, NULL AS A_below,
@@ -438,10 +438,10 @@
                 INNER JOIN Employee AS R_managed ON R_managed.empid=R_below.employee
           WHERE R_below.employee IS NOT NULL AND R_below.id IS NOT NULL AND R_below.task IS NOT NULL
             AND R_btask.lead IS NOT NULL AND R_managed.birthday IS NOT NULL AND R_managed.lastName IS NOT NULL
-                  ) AS R_union1
- WHERE (R_union1._DISJOINT_!=0 OR R_union1.A_who=R_who.empid)
-   AND (R_union1._DISJOINT_!=1 OR R_union1.A_bday=R_who.birthday)
-   AND (R_union1._DISJOINT_!=1 OR R_union1.A_who=R_who.empid)
+                  ) AS G_union1
+ WHERE (G_union1._DISJOINT_!=0 OR G_union1.A_who=R_who.empid)
+   AND (G_union1._DISJOINT_!=1 OR G_union1.A_bday=R_who.birthday)
+   AND (G_union1._DISJOINT_!=1 OR G_union1.A_who=R_who.empid)
    AND R_who.birthday IS NOT NULL AND R_who.empid IS NOT NULL AND R_who.lastName="Smith"
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
@@ -473,7 +473,7 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_union1.A_name AS A_name
+SELECT G_union1.A_name AS A_name
   FROM Employee AS R_who
        INNER JOIN (
          SELECT R_above.id AS A_above, R_above.task AS A_atask, NULL AS A_bday, NULL AS A_below,
@@ -493,11 +493,11 @@
                 INNER JOIN Employee AS R_managed ON R_managed.empid=R_below.employee
           WHERE R_below.employee IS NOT NULL AND R_below.id IS NOT NULL AND R_below.task IS NOT NULL
             AND R_btask.lead IS NOT NULL AND R_managed.birthday IS NOT NULL AND R_managed.lastName IS NOT NULL
-                  ) AS R_union1
- WHERE (R_union1._DISJOINT_!=0 OR R_union1.A_who=R_who.empid)
-   AND (R_union1._DISJOINT_!=1 OR R_union1.A_who=R_who.empid)
-   AND (R_union1._DISJOINT_!=1 OR R_who.birthday=R_union1.A_bday)
-   AND R_union1.A_bday IS NOT NULL AND R_who.empid IS NOT NULL AND R_who.lastName="Smith"
+                  ) AS G_union1
+ WHERE (G_union1._DISJOINT_!=0 OR G_union1.A_who=R_who.empid)
+   AND (G_union1._DISJOINT_!=1 OR G_union1.A_who=R_who.empid)
+   AND (G_union1._DISJOINT_!=1 OR R_who.birthday=G_union1.A_bday)
+   AND G_union1.A_bday IS NOT NULL AND R_who.empid IS NOT NULL AND R_who.lastName="Smith"
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
     assert(transformed === parsed)
@@ -517,7 +517,7 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp.lastName AS A_empName, R_opt1.A_grandManagName AS A_grandManagName, R_opt1.A_managName AS A_managName
+SELECT R_emp.lastName AS A_empName, G_opt1.A_grandManagName AS A_grandManagName, G_opt1.A_managName AS A_managName
   FROM Employee AS R_emp
        LEFT OUTER JOIN (
        SELECT R_emp.empid AS A_emp, R_grandManager.lastName AS A_grandManagName, R_manager.manager AS A_grandManager, R_manager.lastName AS A_managName, R_emp.manager AS A_manager, 1 AS _DISJOINT_
@@ -526,7 +526,7 @@
               INNER JOIN Employee AS R_grandManager ON R_grandManager.empid=R_manager.manager
         WHERE R_emp.empid IS NOT NULL AND R_emp.manager IS NOT NULL AND R_grandManager.lastName IS NOT NULL
           AND R_manager.lastName IS NOT NULL AND R_manager.manager IS NOT NULL
-                  ) AS R_opt1 ON R_opt1.A_emp=R_emp.empid
+                  ) AS G_opt1 ON G_opt1.A_emp=R_emp.empid
  WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
@@ -546,18 +546,18 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp.lastName AS A_empName, R_opt1.A_grandManagName AS A_grandManagName
+SELECT R_emp.lastName AS A_empName, G_opt1.A_grandManagName AS A_grandManagName
   FROM ( SELECT 1 AS _EMPTY_ ) AS _EMPTY_
        LEFT OUTER JOIN (
        SELECT R_taskLead.manager AS A_emp, R_grandManager.lastName AS A_grandManagName, R_taskLead.manager AS A_grandManager, R_taskLead.empid AS A_taskLead, 1 AS _DISJOINT_
          FROM Employee AS R_taskLead
               INNER JOIN Employee AS R_grandManager ON R_grandManager.empid=R_taskLead.manager
         WHERE R_grandManager.lastName IS NOT NULL AND R_taskLead.empid IS NOT NULL AND R_taskLead.manager IS NOT NULL
-                  ) AS R_opt1 ON 1=1
+                  ) AS G_opt1 ON 1=1
        INNER JOIN Employee AS R_emp
- WHERE (R_opt1._DISJOINT_ IS NULL OR R_emp.empid=R_opt1.A_emp)
+ WHERE (G_opt1._DISJOINT_ IS NULL OR R_emp.empid=G_opt1.A_emp)
    AND R_emp.lastName IS NOT NULL
-   AND R_opt1.A_emp IS NOT NULL
+   AND G_opt1.A_emp IS NOT NULL
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
     assert(transformed === parsed)
@@ -578,10 +578,10 @@
 """).get
     val sqlParser = Sql()
     val parsed = sqlParser.parseAll(sqlParser.select, """
-SELECT R_emp.lastName AS A_empName, R_opt1.A_grandManagName AS A_grandManagName, R_opt1.A_managName AS A_managName
+SELECT R_emp.lastName AS A_empName, G_opt1.A_grandManagName AS A_grandManagName, G_opt1.A_managName AS A_managName
   FROM Employee AS R_emp
        LEFT OUTER JOIN (
-       SELECT R_emp.empid AS A_emp, R_opt2.A_grandManagName AS A_grandManagName, R_opt2.A_grandManager AS A_grandManager, R_manager.lastName AS A_managName, R_emp.manager AS A_manager, 1 AS _DISJOINT_
+       SELECT R_emp.empid AS A_emp, G_opt2.A_grandManagName AS A_grandManagName, G_opt2.A_grandManager AS A_grandManager, R_manager.lastName AS A_managName, R_emp.manager AS A_manager, 1 AS _DISJOINT_
          FROM Employee AS R_emp
               INNER JOIN Employee AS R_manager ON R_manager.empid=R_emp.manager
               LEFT OUTER JOIN (
@@ -589,11 +589,11 @@
                 FROM Employee AS R_manager
                      INNER JOIN Employee AS R_grandManager ON R_grandManager.empid=R_manager.manager
                WHERE R_grandManager.lastName IS NOT NULL AND R_manager.empid IS NOT NULL AND R_manager.manager IS NOT NULL
-                         ) AS R_opt2 ON R_opt2.A_manager=R_emp.manager
+                         ) AS G_opt2 ON G_opt2.A_manager=R_emp.manager
         WHERE R_emp.empid IS NOT NULL
           AND R_emp.manager IS NOT NULL
           AND R_manager.lastName IS NOT NULL
-                  ) AS R_opt1 ON R_opt1.A_emp=R_emp.empid
+                  ) AS G_opt1 ON G_opt1.A_emp=R_emp.empid
  WHERE R_emp.empid IS NOT NULL AND R_emp.lastName IS NOT NULL
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
@@ -624,21 +624,21 @@
        SELECT R_emp1.birthday AS A_birthday, R_emp1.empid AS A_emp1, 1 AS _DISJOINT_
          FROM Employee AS R_emp1
         WHERE R_emp1.birthday IS NOT NULL AND R_emp1.empid IS NOT NULL
-                  ) AS R_opt1 ON R_opt1.A_emp1=R_emp1.empid
+                  ) AS G_opt1 ON G_opt1.A_emp1=R_emp1.empid
        INNER JOIN Employee AS R_emp2
        LEFT OUTER JOIN (
        SELECT R_emp2.birthday AS A_birthday, R_emp2.empid AS A_emp2, 3 AS _DISJOINT_
          FROM Employee AS R_emp2
         WHERE R_emp2.birthday IS NOT NULL AND R_emp2.empid IS NOT NULL
-                  ) AS R_opt3 ON (R_opt1._DISJOINT_ IS NULL OR R_opt3.A_birthday=R_opt1.A_birthday) AND R_opt3.A_emp2=R_emp2.empid
+                  ) AS G_opt3 ON (G_opt1._DISJOINT_ IS NULL OR G_opt3.A_birthday=G_opt1.A_birthday) AND G_opt3.A_emp2=R_emp2.empid
        INNER JOIN Employee AS R_emp3
        INNER JOIN Employee AS R_emp4
- WHERE (R_opt1._DISJOINT_ IS NULL OR R_emp3.birthday=R_opt1.A_birthday)
-   AND (R_opt1._DISJOINT_ IS NULL OR R_emp4.birthday=R_opt1.A_birthday)
+ WHERE (G_opt1._DISJOINT_ IS NULL OR R_emp3.birthday=G_opt1.A_birthday)
+   AND (G_opt1._DISJOINT_ IS NULL OR R_emp4.birthday=G_opt1.A_birthday)
    AND R_emp1.empid IS NOT NULL AND R_emp1.lastName IS NOT NULL AND R_emp1.lastName<R_emp2.lastName
    AND R_emp2.empid IS NOT NULL AND R_emp2.lastName IS NOT NULL AND R_emp2.lastName<R_emp3.lastName
    AND R_emp3.empid IS NOT NULL AND R_emp3.lastName IS NOT NULL AND R_emp3.lastName<R_emp4.lastName
-   AND R_emp4.empid IS NOT NULL AND R_emp4.lastName IS NOT NULL AND R_opt1.A_birthday IS NOT NULL
+   AND R_emp4.empid IS NOT NULL AND R_emp4.lastName IS NOT NULL AND G_opt1.A_birthday IS NOT NULL
 """).get
     val transformed = RDB2RDF(db, sparqlSelect, StemURI("http://hr.example/DB/"), false, false)
     assert(transformed === parsed)