Skip to content

Commit

Permalink
Merge branch 'master' into proper_repr
Browse files Browse the repository at this point in the history
Conflicts:
	raco/expression/expression.py
  • Loading branch information
dhalperi committed Jul 24, 2014
2 parents 626bbab + 5d27775 commit 4444161
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
11 changes: 8 additions & 3 deletions raco/expression/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,19 @@ def get_position(self, scheme, state_scheme=None):

class UnnamedAttributeRef(AttributeRef):

def __init__(self, position):
def __init__(self, position, debug_info=None):
if debug_info is None:
debug_info = "${}".format(position)
self.debug_info = debug_info
self.position = position

def __str__(self):
return "$%s" % (self.position)
return "%s" % (self.debug_info)

def __repr__(self):
return "{op}({pos!r})".format(op=self.opname(), pos=self.position)
return "{op}({pos!r}, {dbg!r})".format(op=self.opname(),
pos=self.position,
dbg=self.debug_info)

def __eq__(self, other):
return (other.__class__ == self.__class__
Expand Down
4 changes: 2 additions & 2 deletions raco/myrial/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NestedAggregateException(Exception):
pass


class InvalidAttributeRefException(Exception):
class NonGroupedAccessException(Exception):
'''Attempting to access a non-grouping term in an aggregate expression'''
pass

Expand Down Expand Up @@ -73,7 +73,7 @@ def hoist_node(sexpr):
# after the GroupBy
input_pos = sexpr.get_position(input_scheme)
if input_pos not in group_mappings:
raise InvalidAttributeRefException(str(sexpr))
raise NonGroupedAccessException(str(sexpr))
output_pos = group_mappings[input_pos]
return raco.expression.UnnamedAttributeRef(output_pos)

Expand Down
5 changes: 4 additions & 1 deletion raco/myrial/multiway.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ def rewrite_node(sexpr):
op = from_args[sexpr.relational_expression]
scheme = op.scheme()

debug_info = None
if not sexpr.field:
offset = 0
elif isinstance(sexpr.field, int):
if sexpr.field >= len(scheme):
raise ColumnIndexOutOfBounds(str(sexpr))
offset = sexpr.field
else:
assert isinstance(sexpr.field, basestring)
offset = scheme.getPosition(sexpr.field)
debug_info = sexpr.field

offset += base_offsets[sexpr.relational_expression]
return expression.UnnamedAttributeRef(offset)
return expression.UnnamedAttributeRef(offset, debug_info)

def recursive_eval(sexpr):
"""Rewrite a node and all its descendents"""
Expand Down
2 changes: 1 addition & 1 deletion raco/myrial/query_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def test_aggregate_illegal_colref(self):
STORE(out, OUTPUT);
""" % self.emp_key

with self.assertRaises(raco.myrial.groupby.InvalidAttributeRefException): # noqa
with self.assertRaises(raco.myrial.groupby.NonGroupedAccessException): # noqa
self.check_result(query, None)

def test_nested_aggregates_are_illegal(self):
Expand Down

0 comments on commit 4444161

Please sign in to comment.