table2: added support for inpput array instead of SQL