DataSystemsLab / recdb-postgresql

RecDB is a recommendation engine built entirely inside PostgreSQL
362 stars 43 forks source link

Column name not recognized by materialized recommender #2

Closed claudiosilvestri closed 10 years ago

claudiosilvestri commented 10 years ago

After recommender materialization a (previously working) recommendation query does not work anymore.

How to reproduce the problem: 0) load the movie dataset 1) verify that the query works 2) materialize the recommender 3) verify that the query fails 4) drop the recommender 5) verify that the query works

Here is the complete list of SQL statements (except point 0):

CREATE RECOMMENDER MovieRec ON ml_ratings USERS FROM userid ITEMS FROM itemid EVENTS FROM ratingid USING ItemCosCF; SELECT * FROM ml_ratings R RECOMMEND R.itemid TO R.userid ON R.ratingval USING ItemCosCF WHERE R.userid = 1 ORDER BY R.ratingval LIMIT 10; SELECT * FROM ml_ratings R RECOMMEND R.itemid TO R.userid ON R.ratingval USING ItemCosCF WHERE R.userid = 1 ORDER BY R.ratingval LIMIT 10;

ERROR: column r.ratingval does not exist at character 62 STATEMENT: SELECT * FROM ml_ratings R RECOMMEND R.itemid TO R.userid ON R.ratingval USING ItemCosCF WHERE R.userid = 1 ORDER BY R.ratingval LIMIT 10;

DROP RECOMMENDER MovieRec; SELECT * FROM ml_ratings R RECOMMEND R.itemid TO R.userid ON R.ratingval USING ItemCosCF WHERE R.userid = 1 ORDER BY R.ratingval LIMIT 10;

TheSoundDefense commented 10 years ago

Hi,

In this case, there appears to be a parameter mismatch. The recommender was built on ratingid, but the query is performed on ratingval. In the case of a CREATE RECOMMENDER statement, the EVENTS FROM column should be the rating value, instead of the rating id, for ratings to be accurate.

In any case, the error message comes from that mismatch between ratingid and ratingval. When you reference a created recommender, RecDB assumes that all of the provided columns will exactly match those used in the CREATE RECOMMENDER statement, and that admittedly cryptic error message is a result of that internal assumption. In the future we may handle this by creating a more useful error message, or by treating this situation as if there was no recommender created and generating one on-the-fly.

Thank you for alerting us to this!

TheSoundDefense commented 10 years ago

Fixed the README, which contained the erroneous CREATE statement.