0

I'm, trying to create a prediction of product using predictor gem and ip_address but rails spits out

no such function: array_agg

someone have any idea what this array_agg mean? thank's

gem link https://github.com/Pathgather/predictor

ActiveRecord::StatementInvalid: SQLite3::SQLException: no such function: array_agg: SELECT ip_address, array_to_json(array_agg(product_id)) as product_ids FROM impressions GROUP BY ip_address

 impressions_data = Impression.connection.execute('SELECT ip_address, array_to_json(array_agg(product_id)) as product_ids FROM impressions GROUP BY ip_address')
    impressions_data.each { |row| recommender.impressions.add_to_set(row['ip_address'], eval(row['product_ids'])) }
  • 1
    Please add link to `prediction` gem. I can't google it. – mikdiet Jan 22 '17 at 07:43
  • how this can be a duplicate question? explain me @MikDiet –  Jan 22 '17 at 07:48
  • 1
    You use `postgres` specific function in `sqlite` @jjplack – mikdiet Jan 22 '17 at 07:49
  • what?? first i'm not using postgres and neither mysql, so this question is gem relationship with the db function! in this case sqlite –  Jan 22 '17 at 07:52
  • Either your code or a gem you are using is executing a query that uses a function that is specific to the Postgresql database engine. Sqlite, which is what your code is running, does not support the `array_agg` function. I just looked at the source for the predictor gem; that gem does not appear to generate any queries that use the `array_agg` function (or any other queries that I could find) so that gem is unlikely to be the cause of your problem. I recommend you find the MCVE for your problem and then ask again, if needed. – Wayne Conrad Jan 22 '17 at 11:43

1 Answers1

0

The gem seems to build database queries using the array_agg function. array_agg is not available in SQLite nor in MySQL.

You will have to switch to PostgreSQL to use this gem.

spickermann
  • 100,941
  • 9
  • 101
  • 131