Sharding: query_chooser(query) example broken
(This matters since basically the only sqlalchemy sharding documentation is in this one example)
http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/sharding/attribute_shard.py
The line numbers refer to the original attribute_shard.py. I have attached my own, to illustrate the problem
on line 134: if binary.left is weather_locations.c.continent:
This always evaluates as False.
It should be reached by e.g. Line 194: assert t.reports0.temperature == 80.0
This indeed calls the query_choser, but since there is a catchall, which just returns all the shards, it works, and the actual problem remains unnoticed. However, the whole point of sharding (and therefore the query_chooser), is to only search the shards where (parts of) the results can be found.
The fix is not clear to me. Should the instances compared on Line 135 indeed be the same? Should another comparison be made? Which one?
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.5.7 (automated comment)
- Log in to comment
the shard example had been updated for 0.5, where we now say "MyClass.attribute" rather than "mytable.c.column" in most ORM cases, and the comparison of "is this column X the same column as that of Y" is better accomplished using the
shares_lineage()
method. updated in 766578f13a27ac9e2081b898319380f886e267c1 ed83a844bb143c5b04514800907726e875bf1e82