[Checkins] SVN: Sandbox/adamg/ocql/trunk/src/ocql/ still problems with alias

Adam Groszer agroszer at gmail.com
Tue Aug 26 03:56:40 EDT 2008


Log message for revision 90262:
  still problems with alias

Changed:
  U   Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.txt
  U   Sandbox/adamg/ocql/trunk/src/ocql/parser/parser.txt
  U   Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.txt
  U   Sandbox/adamg/ocql/trunk/src/ocql/tests/run.txt

-=-
Modified: Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.txt	2008-08-26 07:55:38 UTC (rev 90261)
+++ Sandbox/adamg/ocql/trunk/src/ocql/compiler/compiler.txt	2008-08-26 07:56:39 UTC (rev 90262)
@@ -118,3 +118,12 @@
     Head(Reduce(<type 'set'>, `0`, Lambda i: `1`, +, Iter(<type 'list'>, Lambda i: Single(<type 'list'>, i), Make(<type 'list'>, <type 'set'>, ICourse))))
     >>> run.code
     'reduce(operator.add, map(lambda i: 1, reduce(operator.add, map(lambda i: [i], list(metadata.getAll("ICourse"))), [])), 0)'
+
+
+    >>> aopt, run = make("set [ c in ICourse; a as c.credits; a > 3 | c.code ]")
+    >>> aopt
+    Head(Iter(<type 'set'>, Lambda c: Iter(<type 'set'>,
+    Lambda a: Single(<type 'set'>, a), Single(<type 'set'>, c.credits)),
+    Make(<type 'set'>, <type 'set'>, ICourse)))
+    >>> run.code
+    breaks: where is a>3 'reduce(set.union, map(lambda c: reduce(set.union, map(lambda a: set([a]), set([c.credits])), set()), set(metadata.getAll("ICourse"))), set())'

Modified: Sandbox/adamg/ocql/trunk/src/ocql/parser/parser.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/parser/parser.txt	2008-08-26 07:55:38 UTC (rev 90261)
+++ Sandbox/adamg/ocql/trunk/src/ocql/parser/parser.txt	2008-08-26 07:56:39 UTC (rev 90262)
@@ -6,6 +6,8 @@
 Output: Queryobject tree
 
 The task of the parser is to parse the inputted string to Queryobject tree.
+This Queryobject tree can be manipulated and converted later easier.
+See the queryobject.txt for further details.
 
 For the syntax see ../USAGE.txt
 
@@ -134,3 +136,10 @@
     >>> QueryParser("len ( set [ i in IStaff | i ] ) / len ( set [ j in IVisitingStaff | j ] )")(None)
     Head(Div(Count(Query(<type 'set'>, In(Identifier(i), Identifier(IStaff)), Identifier(i))),
     Count(Query(<type 'set'>, In(Identifier(j), Identifier(IVisitingStaff)), Identifier(j)))))
+
+    >>> QueryParser("set [ c in ICourse; a as c.credits; a > 3 | c.code ]")(None)
+    Head(Query(<type 'set'>,
+    In(Identifier(c), Identifier(ICourse));
+    Alias(Identifier(a), Property(Identifier(c), Identifier(credits)));
+    Gt(Identifier(a), Constant(3)),
+    Property(Identifier(c), Identifier(code))))

Modified: Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.txt	2008-08-26 07:55:38 UTC (rev 90261)
+++ Sandbox/adamg/ocql/trunk/src/ocql/rewriter/rewriter.txt	2008-08-26 07:56:39 UTC (rev 90262)
@@ -161,7 +161,7 @@
     >>> opt = QueryOptimizer(qo)()
     >>> alg = Rewriter(opt)()
     >>> print str(alg)
-    Head(Iter(<type 'set'>, Lambda c: Iter(<type 'set'>, 
+    breaks: where is a>3 Head(Iter(<type 'set'>, Lambda c: Iter(<type 'set'>,
     Lambda a: Single(<type 'set'>, a), Single(<type 'set'>, c.credits)),
     Make(<type 'set'>, <type 'set'>, ICourse)))
 
@@ -169,6 +169,6 @@
     >>> opt = QueryOptimizer(qo)()
     >>> alg = Rewriter(opt)()
     >>> print str(alg)
-    Head(Iter(<type 'set'>, Lambda s: 
-    Iter(<type 'set'>, Lambda a: Single(<type 'set'>, a), Single(<type 'set'>, s.major.address.street)), 
+    Head(Iter(<type 'set'>, Lambda s:
+    Iter(<type 'set'>, Lambda a: Single(<type 'set'>, a), Single(<type 'set'>, s.major.address.street)),
     Make(<type 'set'>, <type 'set'>, IStudent)))

Modified: Sandbox/adamg/ocql/trunk/src/ocql/tests/run.txt
===================================================================
--- Sandbox/adamg/ocql/trunk/src/ocql/tests/run.txt	2008-08-26 07:55:38 UTC (rev 90261)
+++ Sandbox/adamg/ocql/trunk/src/ocql/tests/run.txt	2008-08-26 07:56:39 UTC (rev 90262)
@@ -69,4 +69,11 @@
 
     >>> run = run.reanalyze()
     >>> sorted(list(run.execute()))
-    ['C1', 'C2', 'C3']
\ No newline at end of file
+    ['C1', 'C2', 'C3']
+
+
+
+    >>> engine = OCQLEngine()
+    >>> run = engine.compile("set [ c in ICourse; a as c.credits; a > 2 | c.code ]")
+    >>> sorted(run.execute())
+    ['C2', 'C3']



More information about the Checkins mailing list