dwiel / graphcore

Graphcore is a python library which allows you to query a computational graph structure backed by multiple databases, python functions and/or 3rd party services
11 stars 2 forks source link

allow for expressing invariance rules and optimizations around them #34

Open dwiel opened 8 years ago

dwiel commented 8 years ago

In some cases I've written rules like this:

@gc.rule(['location.id'], 'location.location_months.location.id')                
def location_location_months_location_id(id):                                    
    return id

Because this transformation is opaque to graphcore (it sees it as a python function) and so can't optimize across that boundary as in this case:

location.location_months.location.date_of_first_email = <SQLQuery tables:locations; selects:locations.date_of_first_email; where:{} input_mapping:{'id': 'locations.id'}; limit:None; one_column:True; first:True>(location.location_months.location.id) 
location.establishment_type.name, location.name, location.establishment_type.id, location.house_state, location.id = <SQLQuery tables:establishment_types, locations; selects:establishment_types.name, locations.name, locations.establishment_type_id, locations.house_state, locations.id; where:{'locations.house_state': 'release', 'establishment_types.id': 'locations.establishment_type_id'} input_mapping:{}; limit:None; one_column:False; first:False>() Cardinality.many 

these SQLQueries should be mergable, but since there is this python function inbetween, it can't.