I'm trying to convert a simple Impala sql query to an ibis query in python, but I'm having trouble understanding ibis's syntax when converting from sql.

So far, I've tried this:

agg = joblist_table_handle.lastupdatedate.max()
joblist = joblist_table_handle.group_by('id').aggregate(agg).sort_by('lastupdatedate').execute()

I'm hoping to get my result close to the sql query:

SELECT id, max(lastupdatedate) 
FROM joblist_table
GROUP BY id
SORT BY lastupdatedate

Any help is appreciated.

1 Answers

1
Phillip Cloud On Best Solutions

You need to name your aggregation (note the last_update_date=agg keyword argument passed to the aggregate call):

agg = joblist_table_handle.lastupdatedate.max()
joblist = joblist_table_handle.group_by('id').aggregate(last_update_date=agg).sort_by('last_update_date').execute()