[Swift-commit] r4986 - provenancedb
lgadelha at ci.uchicago.edu
lgadelha at ci.uchicago.edu
Tue Aug 16 08:42:44 CDT 2011
Author: lgadelha
Date: 2011-08-16 08:42:42 -0500 (Tue, 16 Aug 2011)
New Revision: 4986
Modified:
provenancedb/ProvSQL.g
Log:
Minor fixes.
Modified: provenancedb/ProvSQL.g
===================================================================
--- provenancedb/ProvSQL.g 2011-08-11 18:22:57 UTC (rev 4985)
+++ provenancedb/ProvSQL.g 2011-08-16 13:42:42 UTC (rev 4986)
@@ -86,38 +86,42 @@
HashSet<String> fromRels = new HashSet<String>();
String fromq = " FROM ";
Iterator<DefaultEdge> i = joinEdges.iterator();
- while(i.hasNext()) {
- DefaultEdge aux = i.next();
- // If ds_in or ds_out were not in the original select clause's relations and they are on the the joinEdges
- // then one has to make sure that both consumed and produced datasets are considered in the join so there
- // is no loss of information. One alternative, implemented here, is to replace these occurrences by the ds
- // view, which is an union of ds_in and ds_out.
- if(qrels.contains("ds_in") || qrels.contains("ds_out")) {
- fromRels.add(schemaGraph.getEdgeSource(aux));
- fromRels.add(schemaGraph.getEdgeTarget(aux));
- }
- else {
- if(aux.equals(schemaGraph.getEdge("ds_in","proc")) ||
- aux.equals(schemaGraph.getEdge("ds_in","ds")) ||
- aux.equals(schemaGraph.getEdge("ds_out","proc")) ||
- aux.equals(schemaGraph.getEdge("ds_out","ds"))) {
- fromRels.add("ds");
- fromRels.add("ds_use");
- fromRels.add("proc");
- }
- else {
+ Iterator<String> k = qrels.iterator();
+ if(qrels.size() == 1)
+ fromRels.add(k.next());
+ else
+ while(i.hasNext()) {
+ DefaultEdge aux = i.next();
+ // If ds_in or ds_out were not in the original select clause's relations and they are on the the joinEdges
+ // then one has to make sure that both consumed and produced datasets are considered in the join so there
+ // is no loss of information. One alternative, implemented here, is to replace these occurrences by the ds
+ // view, which is an union of ds_in and ds_out.
+ if(qrels.contains("ds_in") || qrels.contains("ds_out")) {
fromRels.add(schemaGraph.getEdgeSource(aux));
fromRels.add(schemaGraph.getEdgeTarget(aux));
}
+ else {
+ if(aux.equals(schemaGraph.getEdge("ds_in","proc")) ||
+ aux.equals(schemaGraph.getEdge("ds_in","ds")) ||
+ aux.equals(schemaGraph.getEdge("ds_out","proc")) ||
+ aux.equals(schemaGraph.getEdge("ds_out","ds"))) {
+ fromRels.add("ds");
+ fromRels.add("ds_use");
+ fromRels.add("proc");
+ }
+ else {
+ fromRels.add(schemaGraph.getEdgeSource(aux));
+ fromRels.add(schemaGraph.getEdgeTarget(aux));
+ }
+ }
}
- }
Iterator<String> j = fromRels.iterator();
if(j.hasNext())
fromq += j.next();
while(j.hasNext())
fromq+=","+j.next();
-
+
return fromq;
}
@@ -210,9 +214,10 @@
{
schemaGraph = buildGraph();
joinEdges = computeJoinEdges(schemaGraph, relations);
- hasWhereJoinExpression=true;
+ hasWhereJoinExpression=false;
System.out.print("SELECT " + selectClause);
+
fromClause += computeFrom(schemaGraph, joinEdges, relations);
System.out.print(fromClause);
@@ -234,6 +239,10 @@
System.out.print(whereClause);
}
)?
+ |
+ '(' { System.out.print("("); }
+ squery
+ ')' { System.out.print(")"); }
;
selectExpression
@@ -276,8 +285,11 @@
;
whereAtom
- : entityAttribute OP (STRING | INT | FLOAT)
- | entityAttribute BETWEEN STRING AND STRING;
+ : entityAttribute
+ OP
+ (STRING | INT | FLOAT)
+ | entityAttribute
+ BETWEEN STRING AND STRING;
entityAttribute : ID (DOT ID)?;
More information about the Swift-commit
mailing list