Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Repeated compilation of the same expression gives different results #1179

Closed
cpcloud opened this issue Oct 21, 2017 · 1 comment
Closed
Assignees
Labels
bug Incorrect behavior inside of ibis impala The Apache Impala backend postgres The PostgreSQL backend
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Oct 21, 2017

This also appears to be due to some global state changing during compilation:

In [1]: con = ibis.postgres.connect(database='ibis_testing')

In [2]: t = con.table('batting')

In [3]: print(t.sort_by(ibis.desc(t.playerID)).count().compile().compile())
SELECT count(%(count_1)s) AS count 
FROM batting AS t0 ORDER BY t0."playerID" DESC

In [4]: con = ibis.postgres.connect(database='ibis_testing')

In [5]: t = con.table('batting')

In [6]: print(t.sort_by(ibis.desc(t.playerID)).count().compile().compile())
SELECT count(%(count_1)s) AS count 
FROM (SELECT t1."playerID" AS "playerID", t1."yearID" AS "yearID", t1.stint AS stint, t1."teamID" AS "teamID", t1."lgID" AS "lgID", t1."G" AS "G", t1."AB" AS "AB", t1."R" AS "R", t1."H" AS "H", t1."X2B" AS "X2B", t1."X3B" AS "X3B", t1."HR" AS "HR", t1."RBI" AS "RBI", t1."SB" AS "SB", t1."CS" AS "CS", t1."BB" AS "BB", t1."SO" AS "SO", t1."IBB" AS "IBB", t1."HBP" AS "HBP", t1."SH" AS "SH", t1."SF" AS "SF", t1."GIDP" AS "GIDP" 
FROM batting AS t1 ORDER BY t1."playerID" DESC) AS t0
@cpcloud cpcloud added bug Incorrect behavior inside of ibis impala The Apache Impala backend postgres The PostgreSQL backend labels Oct 21, 2017
@cpcloud cpcloud added this to the 0.12 milestone Oct 21, 2017
@cpcloud cpcloud self-assigned this Oct 21, 2017
@cpcloud cpcloud changed the title BUG: table.sort_by().count() generates incorrect code BUG: Repeated compilation of the same expression gives different results Oct 21, 2017
@cpcloud
Copy link
Member Author

cpcloud commented Oct 21, 2017

This is due to using toolz.memoize as a decorator, which caches the result of every call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis impala The Apache Impala backend postgres The PostgreSQL backend
Projects
None yet
Development

No branches or pull requests

1 participant