Blog Name Description

Mining data, extracting knowledge, driving improvement...

postgres + python + jdbc = magic

I just happened to have a a really crazy bug that just deserves a small post.

After changing something completely unrelated in a Farm Management ERP system, my colleague Christine said that suddenly the test for the economic report wasn't working anymore.

The economic report is a function living on postgres written in plypthonu (= postgres compatible python) and I came to be the owner of that part of the code.

Since it basically aggregates all the data in the DB, it is kind of sensitive to changes, so I thought, well - let's take a look.

It turns out that a line in a query within the python code was suddenly different.

Something like
  JOIN {type_info} ON ... 
became
  JOIN TIME ypeinfo ON ... 
for no obvious reason.

It was still sound and correct in git, the IDE, ... and it just was different in the DB (yes, not even in the source SQL it was wrong).

Moreover, it could have decided to become "altered" for a few weeks (= the code was a few weeks old), yet it only did so on that day.

After all lots of confusion, I could "fix" the error by renaming the variable {type_info} to {xtype_info} (and another a {type_column} to {xtype_column}).

If you know anything about this other than that something seems to replace "{t(.*)}" by "TIME $1", please let me know!

PS: After thinking a little, I suppose it's neither the fault of postgres nor of python because the problem only occurred in our tests, where all the SQL was transmitted via postgres driver + JDBC. Via pgadmin I could not reproduce the problem.

No comments :

Post a Comment