SELECT
*, (SELECT count(1) FROM unnest(A.b)) AS cnt
FROM A
In Table A, I am trying to count the number of items in column b containing a list of items. The query above works, but I am trying to write a sqlalchemy query as below, but it doesn't work. How can I write the query in sqlalchemy?
session.query(A, func.count(func.unnest(A.b)).label('cnt'))
Thanks in advance! Have a nice day :)